如题所述
Android Studioæ¯ä¸å¥é¢ä¸æ¶é´è¿ä¸é¿çIDEï¼å³éæå¼åç¯å¢ï¼ï¼ç®åå·²ç»å
è´¹åè°·æåAndroidçå¼å人ååæ¾ãAndroid Studio以IntelliJ IDEA为åºç¡ï¼åè
åæ ·æ¯ä¸å¥ç¸å½åºè²çAndroidå¼åç¯å¢ãå¨ä»å¤©çæç« ä¸ï¼æ们å°å
±åäºè§£å¦ä½å建ä¸ä¸ªå
¨æ°Android项ç®ï¼åæ¶å
ååæ¥Android Studioææä¾çå项åè½ä¼å¿ã
ã1.项ç®è®¾ç½®
ããå¨å¼å§ç 游Android Studioçä¸çä¹åï¼å¤§å®¶é¦å éè¦ç¹å»æ¤å¤ä¸è½½å¹¶è¿è¡å®è£ ã请注æï¼åä½å¿ é¡»äºå å®è£ 好JDK 6æè æ´é«çæ¬ãå¦ææ¯å¨Windowsç³»ç»ç¯å¢ä¸ï¼å å¯å¨.exeæ件ãèåæç §å®è£ å导çæ示ä¸æ¥æ¥å®æãå¦æ大家使ç¨çæ¯OS Xç³»ç»ï¼åé¦å åå»å¯å¨ç£çéåï¼ç¶åå°Android Studioææ½å°èªå·±çåºç¨ç¨åºæ件夹å½ä¸ã
ããå¨æåå®æäºä»¥ä¸å项æ¥éª¤åï¼é£ä¹å¤§å®¶çå¼åç¯å¢åºè¯¥å·²ç»å¾å°äºæ£ç¡®è®¾ç½®ãæ¥ä¸æ¥ï¼æ们å¯ä»¥åå¤å¥½å©ç¨Android Studioå建èªå·±ç第ä¸æ¬¾Androidåºç¨ç¨åºäºãå½å¤§å®¶ç¬¬ä¸æ¬¡å¯å¨Android Studioæ¶ï¼åºè¯¥ä¼çå°è¯¥è½¯ä»¶ç欢è¿å±å¹ï¼å ¶ä¸è¿æä¾ä¸äºé项ãæ导æ们以æ¤ä¸ºèµ·ç¹è¿åºAndroidåºç¨å¼åç第ä¸æ¥ã
ããå¨ä»å¤©çæç¨ä¸ï¼æ们å°éæ©âNew Projectï¼æ°é¡¹ç®ï¼âé项ãä¸è¿å¦æ大家å¸ææEclipseçå ¶å®ç¯å¢ä¸çç°æ项ç®è½¬å为Android Studio项ç®ï¼ä¹å¯ä»¥éæ©âImport Projectï¼å¯¼å ¥é¡¹ç®ï¼âãAndroid Studioè½å¤å°Eclipse项ç®è½¬æ¢ä¸ºAndroid Studio项ç®ï¼å¹¶å¨é¡¹ç®ä¸ä¸ºç¨æ·æä¾å¿ è¦çé ç½®æ件ã
ããå¦æ大家å¨é项å表ä¸ç¹å»äºâOpen Projectï¼æå¼é¡¹ç®ï¼âï¼åå¯ä»¥å¼å¯å·²ç»å©ç¨Android Studioæè IntelliJ IDEAå建åºç项ç®ãèéæ©âCheck out from Version Controlï¼çæ¬æ§å¶æ£æ¥ï¼âçè¯ï¼å¤§å®¶è½å¤å¯¹å¤äºçæ¬æ§å¶ä¹ä¸ç项ç®å¯æ¬è¿è¡æ£æ¥ãéè¿è¿ç§æ¹å¼ï¼æ们å¯ä»¥å°ç°æ项ç®ä½ä¸ºåºç¡ãå¿«éæ建起æ°çé对æ§çæ¬ã
ããç±äºæ们éè¦ä»é¶å¼å§ï¼å æ¤è¿ééæ©âæ°é¡¹ç®âãè¿æ¶å¤§å®¶ä¼çå°ä¸ä»½é项å表ï¼æ¨å¨å¯¹æ们çæ°é¡¹ç®ä½åºé ç½®ãå¨ä»å¤©çæç¨ä¸ï¼æ们å°å建ä¸æ¬¾ç®åçåºç¨ç¨åºï¼ä¸»è¦ç®çæ¯ä¸ºå¤§å®¶æ¼ç¤ºAndroid Studioä¸æ为éè¦çä¸é¨ååè½ç¹æ§ãç¸ä¿¡å¤§å®¶ä¹åæä¸æ ·ï¼ä¼è®¤ä¸ºâHelloWorldâè¿ä¸ªå称æéåæ¬æ¬¡å¼ååºçæ°é¡¹ç®ã
ããæ£å¦å¤§å®¶å¨ä¸é¢è¿å¹ æªå¾ä¸æçå°ï¼ææèªå·±çåºç¨ç¨åºå½å为HelloWorldï¼å¹¶ä¸ºå ¶è®¾å®äºæ¨¡åå称ãå¦æ大家对IntelliJ IDEAä¸å¤ªçæï¼å¯è½ä¸ç¥é模åè¿ä¸è¥¿å°åºæ¯ä»ä¹ã模åå®é ä¸å°±æ¯ä¸ä¸ªå¯ä»¥è¿è¡ç¼è¯ãè¿è¡ãæµè¯ä»¥åè°è¯çç¬ç«åè½åå ã模åå½ä¸å å«ææºä»£ç ãç¼è¯èæ¬ä»¥åç¨äºç¹å®ä»»å¡çå ¶å®ç»æé¨åã
ããå¨å建æ°é¡¹ç®æ¶ï¼å¤§å®¶è¿å¯ä»¥ä¸ºè¯¥é¡¹ç®è®¾å®è½¯ä»¶å å称ãå¨é»è®¤æ åµä¸ï¼Android Studioä¼å°é¡¹ç®å å称çæåä¸é¡¹å ç´ è®¾ç½®ä¸ºæ¨¡åå称ï¼ä½åªè¦æ¿æã大家å¯ä»¥éæå¯¹å ¶ä½åºåæ´ã
ããå ¶å®è®¾å®å 容è¿å æ¬é¡¹ç®å¨è®¾å¤ä¸çä¿åä½ç½®ãæä½ä¸æ¨èSDKã项ç®ç¼è¯éè¦ä½¿ç¨çSDK以å项ç®ä¸»é¢ççã大家ä¹å¯ä»¥è¦æ±Android Studioå建ä¸ä¸ªActivityç±»ãä¸ºå ¶èªå®ä¹ä¸ä¸ªå¯å¨å¾æ ï¼æè 设å®è¯¥é¡¹ç®æ¯å¦æ¯æGridLayoutãFragmentsãNavigation Draweræè Action Barçã
ããè¿éæ们ä¸ä¼ä¸ºèªå·±çåºç¨ç¨åºå建èªå®ä¹å¾æ ï¼å æ¤å¤§å®¶å¯ä»¥åæ¶âCreate custom launch iconï¼å建èªå®ä¹å¯å¨å¾æ ï¼â项ç®åçå¾éæ¡ãç¹å»âNextï¼ä¸ä¸æ¥ï¼â继ç»è¿è¡å ¶å®é¡¹ç®è®¾ç½®æ¥éª¤ã
ããç±äºæ们å¨ä¹åçæ¥éª¤ä¸å¾éäºâCreate activityï¼å建activityï¼â项ç®çå¾éæ¡ï¼å æ¤è¿é导èªä¼è¦æ±å¤§å®¶å¯¹Android Studioå°ä¸ºæ们å建çActivityç±»è¿è¡é ç½®ã
ããç±äºæ们å°ä»ç©ºç½Activityç±»å¼å§è¿è¡é ç½®ï¼å æ¤å¤§å®¶å¯ä»¥ç¹å»âNextâæ§è¡è®¾ç½®æµç¨çä¸é¢å 个æ¥éª¤ãè¿é大家éè¦å¯¹è¯¥Activityç±»ã主å¸å±ä»¥åç段å¸å±è¿è¡å½åã大家ä¹å¯ä»¥è®¾ç½®å¯¼èªç±»åï¼å¨ä»å¤©ç示ä¾é¡¹ç®ä¸æ们å°å ¶è®¾ç½®ä¸ºâNoneâãä¸é¢è¿å¹ æªå¾æ¾ç¤ºçæ¯æ们ç设置æ¹æ¡çèµ·æ¥æ¯ä»ä¹æ ·åã
ããå¨ç¹å»âFinishâä¹åï¼å¤§å®¶ä¼çå°å¦ä¸å¾æ示çAndroid Studioç¨æ·çé¢ãå ¶ä¸çªå£å·¦ä¾§ä¸ºé¡¹ç®èµæºç®¡çå¨ï¼å³ä¾§å为工ä½åºãå¨Android Studioä¸å¯¹é¡¹ç®è¿è¡è®¾ç½®ä¹åï¼ç°å¨æ们å¯ä»¥éä¸æ¥çAndroid Studioå½ä¸çåé¡¹å ³é®åè½ã
ã2. Androidèæ设å¤
ããæè°Androidèæ设å¤ââæè ç®ç§°AVDââæ¯ä¸å¥æ¨¡æå¨é ç½®æ¹æ¡ï¼å®å 许大家设å®åºä¸å®é æ åµç¸ç¬¦çAndroid设å¤åå·ãè¿å°±è®©å¼åè å¨å¤ç§å¤æ ·ç设å¤å¹³å°ä¸è¿è¡å¹¶æµè¯åºç¨ç¨åºåå¾æ´ä¸ºè½»æ¾ãå¨Androidèæ设å¤åè½çæ¯æä¸ï¼å¤§å®¶å¯ä»¥ä¸ºAndroid模æå¨æå®éè¦æ¨¡æç硬件ä¸è½¯ä»¶ç»åã
ããå建Androidèæ设å¤çé¦éæ¹å¼æ¯éè¿AVD Managerã大家å¯ä»¥å¨Android Studioç¨æ·çé¢çToolsèåä¸ä¾æ¬¡éæ©AndroidãAVD Managerã
ããå¦æ大家ä¹å对å¼åç¯å¢ç设置工ä½æ£ç¡®æ 误ï¼é£ä¹Androidèæ设å¤ç®¡çå¨ççé¢åºè¯¥å¦ä¸å¾æ示ã
ããè¦å建æ°çAVDï¼æ们éè¦ç¹å»å³ä¾§çâNewâ¦âã为AVD设å®å称并å¦ä¸å¾æ示对èæ设å¤è¿è¡é ç½®ãæåç¹å»âOKâ以å建èªå·±ç第ä¸å¥AVDã
ããè¦ä½¿ç¨æ们ååå建好çAVDï¼é¦å éè¦å¨AVD管çå¨çå表ä¸å°å ¶éä¸ï¼ç¶åç¹å»çªå£å³ä¾§çâStartâ¦âãå¦æ大家çAVD设置è¿ç¨æ£ç¡®æ 误ï¼é£ä¹Android模æå¨å¨å¯å¨ååºè¯¥å¦ä¸å¾æ示ã
ããæ¢ç¶Android模æå¨å·²ç»æåå¯å¨å¹¶å¼å§è¿è¡ï¼ç°å¨æ¯æ¶åå¯å¨æ们çåºç¨ç¨åºäºãå¨âRunâèåä¸éæ©âRun âhelloworldââââ没éï¼å¨Android模æå¨ä¸è¿è¡åºç¨ç¨åºå°±æ¯è¿ä¹ç®åã
ã3.å®æ¶å¸å±ï¼Live Layoutï¼
ããAndroid Studioä¸çå®æ¶å¸å±åè½å 许大家å¨æ éå°åºç¨ç¨åºè¿è¡å¨è®¾å¤æè 模æå¨ä¸çåæä¸ï¼ç´æ¥é¢è§åºç¨çç¨æ·çé¢ãå®æ¶å¸å±æ¯ä¸æ¬¾æ为强大çå·¥å ·ï¼è½å¤å¸®å©å¼åè è约大éæ¶é´ãå¨å®æ¶å¸å±ç帮å©ä¸ï¼æ¥çåºç¨ç¨åºç¨æ·çé¢çä»»å¡åå¾è½»æ¾èä¸å¿«æ·ã
ããè¦ä½¿ç¨å®æ¶å¸å±ï¼æ们éè¦åå»å¯¹åºXMLå¸å±æ件并éæ©å·¥ä½åºä¸æ¹çâTextâæ ç¾ãæ¥ä¸æ¥éæ©å·¥ä½åºå³ä¾§çâPreviewâæ ç¾æ¥é¢è§å½åå¸å±ãæ们对XMLå¸å±ä½åºçä»»ä½åæ´é½ä¼ç´æ¥åæ å¨å³ä¾§çé¢è§çªå£å½ä¸ã大家å¯ä»¥æ¥çä¸é¢è¿å¹ æªå¾æ¥æ·±å ¥ç解è¿é¡¹åè½ã
ããå®æ¶å¸å±åè½ä¸ºæ们带æ¥äºè¯¸å¤å¼å¾ç§°éçæ¾èä¼å¿ã举ä¾æ¥è¯´ï¼å¤§å®¶å¯ä»¥å¨Previewé¢æ¿ç第ä¸é¡¹èåä¸éæ©é项ï¼ä»è对å½åæ£å¨ä½¿ç¨çXMLå¸å±éæä½åºè°æ´ãè¬å¦è¯´ï¼å¤§å®¶å¯ä»¥åå«å建ä¸åç纵åä¸æ¨ªåæ¾ç¤ºè§å¾ï¼Android Studioä¼æ¿æ èµ·åå»ºå¿ è¦æ件夹åæ件çä»»å¡ã
ããPreviewé¢æ¿ä¸ç第äºé¡¹èåå 许大家åæ´æ¾ç¤ºå¨Previewé¢æ¿å ç设å¤å¤§å°ã第ä¸é¡¹èåçä½ç¨åæ¯è°æ´è®¾å¤å¨Previewé¢æ¿ä¸çæåï¼è¿æ ·æ们就è½æ´è½»æ¾å°æ¥çåä¸å¥å¸å±æ¹æ¡å¨ä¸åæ¾ç¤ºæ¨¡å¼ï¼çºµåä¸æ¨ªåï¼ä¸çææä¸ä¸»é¢ã
ããPreviewé¢æ¿ä¸ç第å项èåå 许æ们轻æ¾è®¿é®Activityæè å¸å±æ使ç¨ç个å«ç段ãPreviewé¢æ¿è¿å 许大家åæ´å¨å®æ¶å¸å±ä¸ä½¿ç¨çè¯è¨ï¼ä»èè½»æ¾é¢è§ä¸åè¯è¨å¨å¸å±æ¹æ¡ä¸çæ¾ç¤ºææãæå³è¾¹çèåçä½ç¨åæ¯è°æ´APIçæ¬ã
ããPreviewé¢æ¿ä¸è¿å å«å¤é¡¹æ§å¶æºå¶ï¼ä¾å¦å¯¹å¸å±è¿è¡ç¼©æ¾ãéæ°Previewé¢æ¿æè æªåå½åå±å¹ã
ã4.模æ¿
ããAndroid Studioè¿ä¸ºå¼å人åæä¾å¤ç§æ¨¡æ¿é项ï¼ä»è大大æåå¼åé度ãè¿äºæ¨¡æ¿è½èªå¨å建Activity以åå¿ è¦çXMLæ件ã大家è¿å¯ä»¥å©ç¨è¿äºæ¨¡æ¿å建åºè¾ä¸ºåºç¡çAndroidåºç¨ç¨åºï¼å¹¶å°å ¶è¿è¡å¨å®ä½è®¾å¤æè 模æå¨å½ä¸ã
ããå¨Android Studioå½ä¸ï¼æ们å¯ä»¥å¨å建æ°çActivityæ¶ä¸åå建åºå¯¹åºæ¨¡æ¿ãå³é®ç¹å»çªå£å·¦ä¾§é¡¹ç®æµè§å¨ä¸çâpackage nameâ并å¨èåä¸éæ©âNewâï¼èåä»é项å表ä¸ç¹éâActivityâãAndroid Studioéåä¼ä¸ºå¼åè ååºæ¨¡æ¿æ¸ åï¼å ¶ä¸å æ¬Blank ActivityãFullscreen Activity以åTabbed Activityã
ãã大家è¿å¯ä»¥ä»èåä¸éæ©âImage Assetâï¼æ¥ä¸æ¥çå导ä¼æå¼æ们ä¸æ¥æ¥å®æå建æµç¨ãä¸é¢è®©æ们ä¸èµ·æ¥ççå¦ä½ä»¥Login Activity模æ¿ä¸ºåºç¡å建ä¸å¥æ°çActivityãé¦å å¨Acivity模æ¿å表ä¸éæ©Login Activityé项以å¯å¨å建å导ã
ããå¦å¤§å®¶å¨ä¸é¢çæªå¾ä¸æè§ï¼æå·²ç»å°æ°å»ºçActivityå½å为LoginActivityââä¹å°±æ¯ä¸ºactivity login设å®Layout Nameââ并为该Activityæ·»å äºä¸ä¸ªå为Sign Inçæ é¢ãå¨é»è®¤æ åµä¸ï¼å¯¹è¯æ¡ä¸çInclude Google+ sign in项ç®å·²ç»è¢«å¾éãç±äºæ们ä¸æç®å¨ä»å¤©ç示ä¾ä¸ä½¿ç¨Google+ç»å½åè½ï¼å æ¤åæ¶è¯¥å¾é项ã
ãã大家å¯ä»¥éæ©ä¸ºè¿å¥æ°çActivity设å®Hierarchical Parentï¼åå±ç»æï¼ãè¿æ ·å½æ们ç¹å»è®¾å¤ä¸çåéæé®æ¶ï¼åºç¨å°±å°éè¿å¯¼èªè¿åè³ä¸ä¸çé¢ãæ们å°è¿ä¸å段ç空ãå¨ç¹å»âFinishâä¹åï¼Android Studioä¼ä¸ºæ们å建åºå¿ è¦çæ件åæ件夹ãå¦æä¸åè¿å±é¡ºå©ï¼æ们å°å¨é¡¹ç®å½ä¸çå°æ°çActivityä¸Layoutã
ããä¸ä¸å¸å·¥ä½æ¯å¨manifestæ件ä¸å¯¹æ°Activityè¿è¡è®¾ç½®ï¼è¿æ ·å®å°±è½å¨åºç¨ç¨åºå¯å¨æ¶ä½ä¸ºä¸»Activityå 以使ç¨äºã请大家ä¸èµ·æ¥çä¸é¢çmanifestæ件å 容ï¼å ¶ä¸LoginActivityç±»æ¥æèªå·±çæ´»å¨èç¹ã
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.tuts.HelloWorld.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.tuts.HelloWorld.LoginActivity"
android:label="@string/title_activity_login"
android:windowSoftInputMode="adjustResize|stateVisible" >
</activity>
</application>
ãã为äºå¨åºç¨ç¨åºå½ä¸å¯å¨æ们ååå建çLoginActivityï¼é¦å éè¦ç§»é¤åæLoginActivityç±»çæ´»å¨èç¹ï¼ç¶åå©ç¨com.tuts.HelloWorld.LoginActivity代æ¿å åçcom.tuts.HelloWorld.MainActivityãè¿æ ·ä¸æ¥ï¼åºç¨ç¨åºç°å¨å°±å°ä½¿ç¨LoginActivityç±»ä½ä¸ºå ¶ä¸»Activityã
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="za.co.helloworld.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ããå½æ们å¨æ¨¡æå¨å½ä¸å建并è¿è¡èªå·±çåºç¨ç¨åºæ¶ï¼é¦å åºè¯¥ä¼çå°å¦ä¸å¾æ示çæ¾ç¤ºå 容ãè¿æå³çæ们已ç»æåå©ç¨ååå建çLoginActivityç±»å代äºåæç空ç½Activityç±»ã
ã5.Lintå·¥å ·
ãã对代ç è¿è¡æµè¯æ¯ä¸åäºï¼ä½åæ ·éè¦çæ¯ãæ们è¿éè¦å¨ç¼å代ç çåæ¶å¼å ¥åç§æä½³å®è·µãè¿ä¸ä» è½å¤æ¾èæ¹è¿æ§è½è¡¨ç°ï¼ä¹è½å¢å åºç¨ç¨åºçæ´ä½ç¨³å®æ§ãå¦å¤ï¼ç»è¿åçç»æè°æ´ç项ç®å¨ç»´æ¤æ¹é¢ä¹æ´ä¸ºè½»æ¾ã
ããAndroid Studioä¸æä¾çAndroid Lintæ¯ä¸æ¬¾éæåæå·¥å ·ï¼å®è´è´£å¯¹é¡¹ç®æºä»£ç å 以åæãå®è½å¤æ£æµåºåºç¨ç¨åºä¸çæ½å¨æ¼æ´ä»¥åå ¶å®å¯è½è¢«ç¼è¯å¨æ忽ç¥çå ¶å®ä»£ç é®é¢ã
ãã就以ä¸é¢è¿å¹ æªå¾ä¸ºä¾ï¼å¤§å®¶å¯ä»¥çå°è¯¥å¸å±ä¸çLinearLayout并æªå¾å°å®é 使ç¨ãAndroid Lintçä¼å¿å¨äºï¼å®è½å¸®å©æ们éè§è¦åææ¥éä¿¡æ¯çåºç°åå ï¼ä»èæ´è½»æ¾å°ä¿®å¤æè 解å³è¿äºé®é¢ã
ããè¯·å¤§å®¶å »æéå¤ä½¿ç¨Android Studio Lintå·¥å ·çå¥½ä¹ æ¯ï¼è¿è½å¸®å©æ们åç¡®æ£æµå°é¡¹ç®å½ä¸åå¨çæ½å¨é®é¢ãLintå·¥å ·çè³è½åè¯æ们åºç¨ç¨åºä¸æ¯å¦åå¨éå¤çå¾çæè ç¼è¯å 容ã
ããè¦è¿è¡Lintå·¥å ·ï¼å¤§å®¶é¦å éè¦å¨Android StudioçâAnalyzeâèåä¸éæ©âInspect Codeâ¦âãå½Android Studioå®æäºå¯¹é¡¹ç®çæ£æµä¹åï¼å®ä¼å¨çªå£åºé¨æ¾ç¤ºåºåæç»æã请注æï¼é¤äºAndroid Lintä¹å¤ï¼Android Studioè¿æä¾ä¸ç³»åå ¶å®æ£æ¥åè½ãåªéåå»æ个已ç»åç°çé®é¢ï¼ç³»ç»å°±ä¼å¸®å©å¤§å®¶å®ä½å°å¯¹åºæ件ä¸åå¨é®é¢çä½ç½®ã
ã6.å¯å¸å±ç¼è¾å¨
ããAndroid Studioæä¾ä¸å¥å¯å¸å±ç¼è¾å¨ï¼å¤§å®¶å¯ä»¥å¨å ¶ä¸éæææ½åç±»ç¨æ·çé¢ç»ä»¶ã大家è¿å¯ä»¥å¨å¤å±å¹é ç½®ä¸åæ¶æ¥çå¤ç§å¸å±çæ¾ç¤ºææï¼è¿ä¸ç¹æ们å¨åæä¸å·²ç»æå°è¿ã
ããè¿æ¬¾å¯å¸å±ç¼è¾å¨å¨ä½¿ç¨æ¹é¢é常ç´è§ç®åãæ们é¦å éè¦ä¸å¥è¦å¤ççå¸å±æ¹æ¡ãæµè§å°é¡¹ç®ä¸resæ件夹ä¸çlayoutæ件夹ï¼å³é®ç¹å»layoutæ件夹ï¼ç¶åå¨å¼¹åºçèåä¸éæ©New>Layout resource fileã
ããä¸é¢ä¸ºæ°å¸å±è®¾å®ä¸ä¸ªå称ä¸rootå ç´ ï¼èåç¹å»âOKâãAndroid Studioä¼èªå¨å¨çªå£å³ä¾§çç¼è¾å¨å½ä¸æå¼è¯¥å¸å±ã
ããå¨ç¼è¾å¨çåºé¨ï¼å¤§å®¶ä¼çå°ä¸¤ä¸ªæ ç¾ï¼åå«æ¯Designä¸Textãç¹å»Textæ ç¾åç¼è¾å¨å°è¢«æ¿æ´»ï¼è¿æ ·æ们就è½å¯¹å½åéå®çå¸å±æ¹æ¡ä½åºåæ´ã
ããç¹å»Designæ ç¾åä¼æ¿æ´»å¦ä¸å¥ç¼è¾å¨å 容ï¼å ¶ä¸æ¾ç¤ºåºå¸å±çé¢è§ææãè¦åå¸å±å½ä¸æ·»å å ¶å®åè½æ§ç»ä»¶ï¼æ们åªéå°å ¶ä»å¸å±å·¦ä¾§çç»ä»¶å表ä¸æåºå¹¶æ¾å ¥å¸å±å å³å¯ãæ¯çï¼å°±è¿ä¹ç®åã
ã1.项ç®è®¾ç½®
ããå¨å¼å§ç 游Android Studioçä¸çä¹åï¼å¤§å®¶é¦å éè¦ç¹å»æ¤å¤ä¸è½½å¹¶è¿è¡å®è£ ã请注æï¼åä½å¿ é¡»äºå å®è£ 好JDK 6æè æ´é«çæ¬ãå¦ææ¯å¨Windowsç³»ç»ç¯å¢ä¸ï¼å å¯å¨.exeæ件ãèåæç §å®è£ å导çæ示ä¸æ¥æ¥å®æãå¦æ大家使ç¨çæ¯OS Xç³»ç»ï¼åé¦å åå»å¯å¨ç£çéåï¼ç¶åå°Android Studioææ½å°èªå·±çåºç¨ç¨åºæ件夹å½ä¸ã
ããå¨æåå®æäºä»¥ä¸å项æ¥éª¤åï¼é£ä¹å¤§å®¶çå¼åç¯å¢åºè¯¥å·²ç»å¾å°äºæ£ç¡®è®¾ç½®ãæ¥ä¸æ¥ï¼æ们å¯ä»¥åå¤å¥½å©ç¨Android Studioå建èªå·±ç第ä¸æ¬¾Androidåºç¨ç¨åºäºãå½å¤§å®¶ç¬¬ä¸æ¬¡å¯å¨Android Studioæ¶ï¼åºè¯¥ä¼çå°è¯¥è½¯ä»¶ç欢è¿å±å¹ï¼å ¶ä¸è¿æä¾ä¸äºé项ãæ导æ们以æ¤ä¸ºèµ·ç¹è¿åºAndroidåºç¨å¼åç第ä¸æ¥ã
ããå¨ä»å¤©çæç¨ä¸ï¼æ们å°éæ©âNew Projectï¼æ°é¡¹ç®ï¼âé项ãä¸è¿å¦æ大家å¸ææEclipseçå ¶å®ç¯å¢ä¸çç°æ项ç®è½¬å为Android Studio项ç®ï¼ä¹å¯ä»¥éæ©âImport Projectï¼å¯¼å ¥é¡¹ç®ï¼âãAndroid Studioè½å¤å°Eclipse项ç®è½¬æ¢ä¸ºAndroid Studio项ç®ï¼å¹¶å¨é¡¹ç®ä¸ä¸ºç¨æ·æä¾å¿ è¦çé ç½®æ件ã
ããå¦æ大家å¨é项å表ä¸ç¹å»äºâOpen Projectï¼æå¼é¡¹ç®ï¼âï¼åå¯ä»¥å¼å¯å·²ç»å©ç¨Android Studioæè IntelliJ IDEAå建åºç项ç®ãèéæ©âCheck out from Version Controlï¼çæ¬æ§å¶æ£æ¥ï¼âçè¯ï¼å¤§å®¶è½å¤å¯¹å¤äºçæ¬æ§å¶ä¹ä¸ç项ç®å¯æ¬è¿è¡æ£æ¥ãéè¿è¿ç§æ¹å¼ï¼æ们å¯ä»¥å°ç°æ项ç®ä½ä¸ºåºç¡ãå¿«éæ建起æ°çé对æ§çæ¬ã
ããç±äºæ们éè¦ä»é¶å¼å§ï¼å æ¤è¿ééæ©âæ°é¡¹ç®âãè¿æ¶å¤§å®¶ä¼çå°ä¸ä»½é项å表ï¼æ¨å¨å¯¹æ们çæ°é¡¹ç®ä½åºé ç½®ãå¨ä»å¤©çæç¨ä¸ï¼æ们å°å建ä¸æ¬¾ç®åçåºç¨ç¨åºï¼ä¸»è¦ç®çæ¯ä¸ºå¤§å®¶æ¼ç¤ºAndroid Studioä¸æ为éè¦çä¸é¨ååè½ç¹æ§ãç¸ä¿¡å¤§å®¶ä¹åæä¸æ ·ï¼ä¼è®¤ä¸ºâHelloWorldâè¿ä¸ªå称æéåæ¬æ¬¡å¼ååºçæ°é¡¹ç®ã
ããæ£å¦å¤§å®¶å¨ä¸é¢è¿å¹ æªå¾ä¸æçå°ï¼ææèªå·±çåºç¨ç¨åºå½å为HelloWorldï¼å¹¶ä¸ºå ¶è®¾å®äºæ¨¡åå称ãå¦æ大家对IntelliJ IDEAä¸å¤ªçæï¼å¯è½ä¸ç¥é模åè¿ä¸è¥¿å°åºæ¯ä»ä¹ã模åå®é ä¸å°±æ¯ä¸ä¸ªå¯ä»¥è¿è¡ç¼è¯ãè¿è¡ãæµè¯ä»¥åè°è¯çç¬ç«åè½åå ã模åå½ä¸å å«ææºä»£ç ãç¼è¯èæ¬ä»¥åç¨äºç¹å®ä»»å¡çå ¶å®ç»æé¨åã
ããå¨å建æ°é¡¹ç®æ¶ï¼å¤§å®¶è¿å¯ä»¥ä¸ºè¯¥é¡¹ç®è®¾å®è½¯ä»¶å å称ãå¨é»è®¤æ åµä¸ï¼Android Studioä¼å°é¡¹ç®å å称çæåä¸é¡¹å ç´ è®¾ç½®ä¸ºæ¨¡åå称ï¼ä½åªè¦æ¿æã大家å¯ä»¥éæå¯¹å ¶ä½åºåæ´ã
ããå ¶å®è®¾å®å 容è¿å æ¬é¡¹ç®å¨è®¾å¤ä¸çä¿åä½ç½®ãæä½ä¸æ¨èSDKã项ç®ç¼è¯éè¦ä½¿ç¨çSDK以å项ç®ä¸»é¢ççã大家ä¹å¯ä»¥è¦æ±Android Studioå建ä¸ä¸ªActivityç±»ãä¸ºå ¶èªå®ä¹ä¸ä¸ªå¯å¨å¾æ ï¼æè 设å®è¯¥é¡¹ç®æ¯å¦æ¯æGridLayoutãFragmentsãNavigation Draweræè Action Barçã
ããè¿éæ们ä¸ä¼ä¸ºèªå·±çåºç¨ç¨åºå建èªå®ä¹å¾æ ï¼å æ¤å¤§å®¶å¯ä»¥åæ¶âCreate custom launch iconï¼å建èªå®ä¹å¯å¨å¾æ ï¼â项ç®åçå¾éæ¡ãç¹å»âNextï¼ä¸ä¸æ¥ï¼â继ç»è¿è¡å ¶å®é¡¹ç®è®¾ç½®æ¥éª¤ã
ããç±äºæ们å¨ä¹åçæ¥éª¤ä¸å¾éäºâCreate activityï¼å建activityï¼â项ç®çå¾éæ¡ï¼å æ¤è¿é导èªä¼è¦æ±å¤§å®¶å¯¹Android Studioå°ä¸ºæ们å建çActivityç±»è¿è¡é ç½®ã
ããç±äºæ们å°ä»ç©ºç½Activityç±»å¼å§è¿è¡é ç½®ï¼å æ¤å¤§å®¶å¯ä»¥ç¹å»âNextâæ§è¡è®¾ç½®æµç¨çä¸é¢å 个æ¥éª¤ãè¿é大家éè¦å¯¹è¯¥Activityç±»ã主å¸å±ä»¥åç段å¸å±è¿è¡å½åã大家ä¹å¯ä»¥è®¾ç½®å¯¼èªç±»åï¼å¨ä»å¤©ç示ä¾é¡¹ç®ä¸æ们å°å ¶è®¾ç½®ä¸ºâNoneâãä¸é¢è¿å¹ æªå¾æ¾ç¤ºçæ¯æ们ç设置æ¹æ¡çèµ·æ¥æ¯ä»ä¹æ ·åã
ããå¨ç¹å»âFinishâä¹åï¼å¤§å®¶ä¼çå°å¦ä¸å¾æ示çAndroid Studioç¨æ·çé¢ãå ¶ä¸çªå£å·¦ä¾§ä¸ºé¡¹ç®èµæºç®¡çå¨ï¼å³ä¾§å为工ä½åºãå¨Android Studioä¸å¯¹é¡¹ç®è¿è¡è®¾ç½®ä¹åï¼ç°å¨æ们å¯ä»¥éä¸æ¥çAndroid Studioå½ä¸çåé¡¹å ³é®åè½ã
ã2. Androidèæ设å¤
ããæè°Androidèæ设å¤ââæè ç®ç§°AVDââæ¯ä¸å¥æ¨¡æå¨é ç½®æ¹æ¡ï¼å®å 许大家设å®åºä¸å®é æ åµç¸ç¬¦çAndroid设å¤åå·ãè¿å°±è®©å¼åè å¨å¤ç§å¤æ ·ç设å¤å¹³å°ä¸è¿è¡å¹¶æµè¯åºç¨ç¨åºåå¾æ´ä¸ºè½»æ¾ãå¨Androidèæ设å¤åè½çæ¯æä¸ï¼å¤§å®¶å¯ä»¥ä¸ºAndroid模æå¨æå®éè¦æ¨¡æç硬件ä¸è½¯ä»¶ç»åã
ããå建Androidèæ设å¤çé¦éæ¹å¼æ¯éè¿AVD Managerã大家å¯ä»¥å¨Android Studioç¨æ·çé¢çToolsèåä¸ä¾æ¬¡éæ©AndroidãAVD Managerã
ããå¦æ大家ä¹å对å¼åç¯å¢ç设置工ä½æ£ç¡®æ 误ï¼é£ä¹Androidèæ设å¤ç®¡çå¨ççé¢åºè¯¥å¦ä¸å¾æ示ã
ããè¦å建æ°çAVDï¼æ们éè¦ç¹å»å³ä¾§çâNewâ¦âã为AVD设å®å称并å¦ä¸å¾æ示对èæ设å¤è¿è¡é ç½®ãæåç¹å»âOKâ以å建èªå·±ç第ä¸å¥AVDã
ããè¦ä½¿ç¨æ们ååå建好çAVDï¼é¦å éè¦å¨AVD管çå¨çå表ä¸å°å ¶éä¸ï¼ç¶åç¹å»çªå£å³ä¾§çâStartâ¦âãå¦æ大家çAVD设置è¿ç¨æ£ç¡®æ 误ï¼é£ä¹Android模æå¨å¨å¯å¨ååºè¯¥å¦ä¸å¾æ示ã
ããæ¢ç¶Android模æå¨å·²ç»æåå¯å¨å¹¶å¼å§è¿è¡ï¼ç°å¨æ¯æ¶åå¯å¨æ们çåºç¨ç¨åºäºãå¨âRunâèåä¸éæ©âRun âhelloworldââââ没éï¼å¨Android模æå¨ä¸è¿è¡åºç¨ç¨åºå°±æ¯è¿ä¹ç®åã
ã3.å®æ¶å¸å±ï¼Live Layoutï¼
ããAndroid Studioä¸çå®æ¶å¸å±åè½å 许大家å¨æ éå°åºç¨ç¨åºè¿è¡å¨è®¾å¤æè 模æå¨ä¸çåæä¸ï¼ç´æ¥é¢è§åºç¨çç¨æ·çé¢ãå®æ¶å¸å±æ¯ä¸æ¬¾æ为强大çå·¥å ·ï¼è½å¤å¸®å©å¼åè è约大éæ¶é´ãå¨å®æ¶å¸å±ç帮å©ä¸ï¼æ¥çåºç¨ç¨åºç¨æ·çé¢çä»»å¡åå¾è½»æ¾èä¸å¿«æ·ã
ããè¦ä½¿ç¨å®æ¶å¸å±ï¼æ们éè¦åå»å¯¹åºXMLå¸å±æ件并éæ©å·¥ä½åºä¸æ¹çâTextâæ ç¾ãæ¥ä¸æ¥éæ©å·¥ä½åºå³ä¾§çâPreviewâæ ç¾æ¥é¢è§å½åå¸å±ãæ们对XMLå¸å±ä½åºçä»»ä½åæ´é½ä¼ç´æ¥åæ å¨å³ä¾§çé¢è§çªå£å½ä¸ã大家å¯ä»¥æ¥çä¸é¢è¿å¹ æªå¾æ¥æ·±å ¥ç解è¿é¡¹åè½ã
ããå®æ¶å¸å±åè½ä¸ºæ们带æ¥äºè¯¸å¤å¼å¾ç§°éçæ¾èä¼å¿ã举ä¾æ¥è¯´ï¼å¤§å®¶å¯ä»¥å¨Previewé¢æ¿ç第ä¸é¡¹èåä¸éæ©é项ï¼ä»è对å½åæ£å¨ä½¿ç¨çXMLå¸å±éæä½åºè°æ´ãè¬å¦è¯´ï¼å¤§å®¶å¯ä»¥åå«å建ä¸åç纵åä¸æ¨ªåæ¾ç¤ºè§å¾ï¼Android Studioä¼æ¿æ èµ·åå»ºå¿ è¦æ件夹åæ件çä»»å¡ã
ããPreviewé¢æ¿ä¸ç第äºé¡¹èåå 许大家åæ´æ¾ç¤ºå¨Previewé¢æ¿å ç设å¤å¤§å°ã第ä¸é¡¹èåçä½ç¨åæ¯è°æ´è®¾å¤å¨Previewé¢æ¿ä¸çæåï¼è¿æ ·æ们就è½æ´è½»æ¾å°æ¥çåä¸å¥å¸å±æ¹æ¡å¨ä¸åæ¾ç¤ºæ¨¡å¼ï¼çºµåä¸æ¨ªåï¼ä¸çææä¸ä¸»é¢ã
ããPreviewé¢æ¿ä¸ç第å项èåå 许æ们轻æ¾è®¿é®Activityæè å¸å±æ使ç¨ç个å«ç段ãPreviewé¢æ¿è¿å 许大家åæ´å¨å®æ¶å¸å±ä¸ä½¿ç¨çè¯è¨ï¼ä»èè½»æ¾é¢è§ä¸åè¯è¨å¨å¸å±æ¹æ¡ä¸çæ¾ç¤ºææãæå³è¾¹çèåçä½ç¨åæ¯è°æ´APIçæ¬ã
ããPreviewé¢æ¿ä¸è¿å å«å¤é¡¹æ§å¶æºå¶ï¼ä¾å¦å¯¹å¸å±è¿è¡ç¼©æ¾ãéæ°Previewé¢æ¿æè æªåå½åå±å¹ã
ã4.模æ¿
ããAndroid Studioè¿ä¸ºå¼å人åæä¾å¤ç§æ¨¡æ¿é项ï¼ä»è大大æåå¼åé度ãè¿äºæ¨¡æ¿è½èªå¨å建Activity以åå¿ è¦çXMLæ件ã大家è¿å¯ä»¥å©ç¨è¿äºæ¨¡æ¿å建åºè¾ä¸ºåºç¡çAndroidåºç¨ç¨åºï¼å¹¶å°å ¶è¿è¡å¨å®ä½è®¾å¤æè 模æå¨å½ä¸ã
ããå¨Android Studioå½ä¸ï¼æ们å¯ä»¥å¨å建æ°çActivityæ¶ä¸åå建åºå¯¹åºæ¨¡æ¿ãå³é®ç¹å»çªå£å·¦ä¾§é¡¹ç®æµè§å¨ä¸çâpackage nameâ并å¨èåä¸éæ©âNewâï¼èåä»é项å表ä¸ç¹éâActivityâãAndroid Studioéåä¼ä¸ºå¼åè ååºæ¨¡æ¿æ¸ åï¼å ¶ä¸å æ¬Blank ActivityãFullscreen Activity以åTabbed Activityã
ãã大家è¿å¯ä»¥ä»èåä¸éæ©âImage Assetâï¼æ¥ä¸æ¥çå导ä¼æå¼æ们ä¸æ¥æ¥å®æå建æµç¨ãä¸é¢è®©æ们ä¸èµ·æ¥ççå¦ä½ä»¥Login Activity模æ¿ä¸ºåºç¡å建ä¸å¥æ°çActivityãé¦å å¨Acivity模æ¿å表ä¸éæ©Login Activityé项以å¯å¨å建å导ã
ããå¦å¤§å®¶å¨ä¸é¢çæªå¾ä¸æè§ï¼æå·²ç»å°æ°å»ºçActivityå½å为LoginActivityââä¹å°±æ¯ä¸ºactivity login设å®Layout Nameââ并为该Activityæ·»å äºä¸ä¸ªå为Sign Inçæ é¢ãå¨é»è®¤æ åµä¸ï¼å¯¹è¯æ¡ä¸çInclude Google+ sign in项ç®å·²ç»è¢«å¾éãç±äºæ们ä¸æç®å¨ä»å¤©ç示ä¾ä¸ä½¿ç¨Google+ç»å½åè½ï¼å æ¤åæ¶è¯¥å¾é项ã
ãã大家å¯ä»¥éæ©ä¸ºè¿å¥æ°çActivity设å®Hierarchical Parentï¼åå±ç»æï¼ãè¿æ ·å½æ们ç¹å»è®¾å¤ä¸çåéæé®æ¶ï¼åºç¨å°±å°éè¿å¯¼èªè¿åè³ä¸ä¸çé¢ãæ们å°è¿ä¸å段ç空ãå¨ç¹å»âFinishâä¹åï¼Android Studioä¼ä¸ºæ们å建åºå¿ è¦çæ件åæ件夹ãå¦æä¸åè¿å±é¡ºå©ï¼æ们å°å¨é¡¹ç®å½ä¸çå°æ°çActivityä¸Layoutã
ããä¸ä¸å¸å·¥ä½æ¯å¨manifestæ件ä¸å¯¹æ°Activityè¿è¡è®¾ç½®ï¼è¿æ ·å®å°±è½å¨åºç¨ç¨åºå¯å¨æ¶ä½ä¸ºä¸»Activityå 以使ç¨äºã请大家ä¸èµ·æ¥çä¸é¢çmanifestæ件å 容ï¼å ¶ä¸LoginActivityç±»æ¥æèªå·±çæ´»å¨èç¹ã
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.tuts.HelloWorld.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.tuts.HelloWorld.LoginActivity"
android:label="@string/title_activity_login"
android:windowSoftInputMode="adjustResize|stateVisible" >
</activity>
</application>
ãã为äºå¨åºç¨ç¨åºå½ä¸å¯å¨æ们ååå建çLoginActivityï¼é¦å éè¦ç§»é¤åæLoginActivityç±»çæ´»å¨èç¹ï¼ç¶åå©ç¨com.tuts.HelloWorld.LoginActivity代æ¿å åçcom.tuts.HelloWorld.MainActivityãè¿æ ·ä¸æ¥ï¼åºç¨ç¨åºç°å¨å°±å°ä½¿ç¨LoginActivityç±»ä½ä¸ºå ¶ä¸»Activityã
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="za.co.helloworld.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ããå½æ们å¨æ¨¡æå¨å½ä¸å建并è¿è¡èªå·±çåºç¨ç¨åºæ¶ï¼é¦å åºè¯¥ä¼çå°å¦ä¸å¾æ示çæ¾ç¤ºå 容ãè¿æå³çæ们已ç»æåå©ç¨ååå建çLoginActivityç±»å代äºåæç空ç½Activityç±»ã
ã5.Lintå·¥å ·
ãã对代ç è¿è¡æµè¯æ¯ä¸åäºï¼ä½åæ ·éè¦çæ¯ãæ们è¿éè¦å¨ç¼å代ç çåæ¶å¼å ¥åç§æä½³å®è·µãè¿ä¸ä» è½å¤æ¾èæ¹è¿æ§è½è¡¨ç°ï¼ä¹è½å¢å åºç¨ç¨åºçæ´ä½ç¨³å®æ§ãå¦å¤ï¼ç»è¿åçç»æè°æ´ç项ç®å¨ç»´æ¤æ¹é¢ä¹æ´ä¸ºè½»æ¾ã
ããAndroid Studioä¸æä¾çAndroid Lintæ¯ä¸æ¬¾éæåæå·¥å ·ï¼å®è´è´£å¯¹é¡¹ç®æºä»£ç å 以åæãå®è½å¤æ£æµåºåºç¨ç¨åºä¸çæ½å¨æ¼æ´ä»¥åå ¶å®å¯è½è¢«ç¼è¯å¨æ忽ç¥çå ¶å®ä»£ç é®é¢ã
ãã就以ä¸é¢è¿å¹ æªå¾ä¸ºä¾ï¼å¤§å®¶å¯ä»¥çå°è¯¥å¸å±ä¸çLinearLayout并æªå¾å°å®é 使ç¨ãAndroid Lintçä¼å¿å¨äºï¼å®è½å¸®å©æ们éè§è¦åææ¥éä¿¡æ¯çåºç°åå ï¼ä»èæ´è½»æ¾å°ä¿®å¤æè 解å³è¿äºé®é¢ã
ããè¯·å¤§å®¶å »æéå¤ä½¿ç¨Android Studio Lintå·¥å ·çå¥½ä¹ æ¯ï¼è¿è½å¸®å©æ们åç¡®æ£æµå°é¡¹ç®å½ä¸åå¨çæ½å¨é®é¢ãLintå·¥å ·çè³è½åè¯æ们åºç¨ç¨åºä¸æ¯å¦åå¨éå¤çå¾çæè ç¼è¯å 容ã
ããè¦è¿è¡Lintå·¥å ·ï¼å¤§å®¶é¦å éè¦å¨Android StudioçâAnalyzeâèåä¸éæ©âInspect Codeâ¦âãå½Android Studioå®æäºå¯¹é¡¹ç®çæ£æµä¹åï¼å®ä¼å¨çªå£åºé¨æ¾ç¤ºåºåæç»æã请注æï¼é¤äºAndroid Lintä¹å¤ï¼Android Studioè¿æä¾ä¸ç³»åå ¶å®æ£æ¥åè½ãåªéåå»æ个已ç»åç°çé®é¢ï¼ç³»ç»å°±ä¼å¸®å©å¤§å®¶å®ä½å°å¯¹åºæ件ä¸åå¨é®é¢çä½ç½®ã
ã6.å¯å¸å±ç¼è¾å¨
ããAndroid Studioæä¾ä¸å¥å¯å¸å±ç¼è¾å¨ï¼å¤§å®¶å¯ä»¥å¨å ¶ä¸éæææ½åç±»ç¨æ·çé¢ç»ä»¶ã大家è¿å¯ä»¥å¨å¤å±å¹é ç½®ä¸åæ¶æ¥çå¤ç§å¸å±çæ¾ç¤ºææï¼è¿ä¸ç¹æ们å¨åæä¸å·²ç»æå°è¿ã
ããè¿æ¬¾å¯å¸å±ç¼è¾å¨å¨ä½¿ç¨æ¹é¢é常ç´è§ç®åãæ们é¦å éè¦ä¸å¥è¦å¤ççå¸å±æ¹æ¡ãæµè§å°é¡¹ç®ä¸resæ件夹ä¸çlayoutæ件夹ï¼å³é®ç¹å»layoutæ件夹ï¼ç¶åå¨å¼¹åºçèåä¸éæ©New>Layout resource fileã
ããä¸é¢ä¸ºæ°å¸å±è®¾å®ä¸ä¸ªå称ä¸rootå ç´ ï¼èåç¹å»âOKâãAndroid Studioä¼èªå¨å¨çªå£å³ä¾§çç¼è¾å¨å½ä¸æå¼è¯¥å¸å±ã
ããå¨ç¼è¾å¨çåºé¨ï¼å¤§å®¶ä¼çå°ä¸¤ä¸ªæ ç¾ï¼åå«æ¯Designä¸Textãç¹å»Textæ ç¾åç¼è¾å¨å°è¢«æ¿æ´»ï¼è¿æ ·æ们就è½å¯¹å½åéå®çå¸å±æ¹æ¡ä½åºåæ´ã
ããç¹å»Designæ ç¾åä¼æ¿æ´»å¦ä¸å¥ç¼è¾å¨å 容ï¼å ¶ä¸æ¾ç¤ºåºå¸å±çé¢è§ææãè¦åå¸å±å½ä¸æ·»å å ¶å®åè½æ§ç»ä»¶ï¼æ们åªéå°å ¶ä»å¸å±å·¦ä¾§çç»ä»¶å表ä¸æåºå¹¶æ¾å ¥å¸å±å å³å¯ãæ¯çï¼å°±è¿ä¹ç®åã
温馨提示:答案为网友推荐,仅供参考