日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

相对布局(中)

發布時間:2025/3/21 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 相对布局(中) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 對齊至控件的基準線

2. 與父控件的四個邊緣對齊

3. 對齊至父控件的中央

?

1. 對齊至控件的基準線

???

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 tools:context="first.pack.MainActivity$PlaceholderFragment" > 6 7 <TextView 8 android:id="@+id/firstView" 9 android:layout_width="wrap_content" 10 android:layout_height="wrap_content" 11 android:textSize="50sp" 12 android:background="#FF0000" 13 android:text="hello" /> 14 15 <TextView 16 android:layout_width="wrap_content" 17 android:layout_height="wrap_content" 18 android:layout_toRightOf="@+id/firstView" 19 android:layout_alignBaseline="@+id/firstView" //對齊基準線!!! 20 android:background="#00FF00" 21 android:text="mirrorhanyu" /> 22 23 </RelativeLayout>

?

2. 與父控件的四個邊緣對齊

? ? ??

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 tools:context="first.pack.MainActivity$PlaceholderFragment" > 6 7 <TextView 8 android:id="@+id/firstView" 9 android:layout_width="wrap_content" 10 android:layout_height="wrap_content" 11 android:textSize="50sp" 12 android:background="#FF0000" 13 android:layout_alignParentRight="true" //與父控件右邊對齊 14 android:text="hello" /> 15 16 </RelativeLayout>

????

????

???? 當代碼為

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 tools:context="first.pack.MainActivity$PlaceholderFragment" > 6 7 <RelativeLayout 8 android:layout_width="wrap_content" 9 android:layout_height="300dp" 10 android:background="#00FF00"> 11 <TextView 12 android:id="@+id/firstView" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:textSize="50sp" 16 android:background="#FF0000" 17 android:layout_alignParentRight="true" //與就近的父控件對齊 18 android:layout_alignParentBottom="true" 19 android:text="hello" /> 20 </RelativeLayout> 21 </RelativeLayout>

????????

?

??????

3. 對齊至父控件的中央

? ? ?? ????

?

轉載于:https://www.cnblogs.com/iMirror/p/3810264.html

總結

以上是生活随笔為你收集整理的相对布局(中)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。