1.在eclipse的安卓代碼中,怎么添加注釋
ctrl+shift+/ (最好不要加注釋)
2.控制元件的寬度
android:layout_width="match_parent"
控制元件的高度
android:layout_height="match_parent"
快速輸入寬度和高度的代碼
w+alt+/(寬度) ,h+alt+/(高度)
3.顯示一張圖片
(1)將圖片匯入專案中
首先下載一張圖片到電腦中的某一位置

接著復制該圖片(ctrl+c)到drawable-hdpi(高解析度)檔案下

此時圖片已匯入專案目錄中
(2)打開src下的MainActivity.java
快速輸入背景圖片的代碼
ba+/
輸入@自動顯示目錄檔案,這時點擊圖片目錄下的檔案夾

在檔案夾下找到相應的圖片

4.代碼
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
5.執行安卓程式,并在cmd中連接模擬器(我用的是mumu模擬器)

常用模擬器埠請參照:模擬器埠號_LiuNan的博客-CSDN博客_mumu模擬器埠
——@LiuNanBlog
模擬器中將顯示該圖片

——@上官可編程
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/301792.html
標籤:其他
下一篇:AVPlayer音頻和視頻播放
