(1)設計方案

黃色布局包含兩個子布局
(2)代碼實作
<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"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/pic1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@drawable/bg1"
></RelativeLayout>
<RelativeLayout
android:layout_below="@id/pic1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@drawable/bg"
></RelativeLayout>
</RelativeLayout>
在android:layout_width="match_parent"中match_parent為默認寬度
android:layout_height="400dp"代表,高度為400像素
android:background="@drawable/bg1"代表background要找到drawable檔案下的bg1圖片
在第一個樣式中分配id要用到@+id
在第一個樣式中,第二個圖片在第一個圖片的下方,這時要用到@id,因為是在pic1的下面
(注:@id后面的名字可以隨便起名)
運行效果

——@上官可編程
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/301787.html
標籤:其他
上一篇:??【Android精進之路-02】安裝Android Studio,認識Android SDK,一步步學習??
下一篇:[iOS開發]網路請求合集
