[英]Layout weight in relative layout
我知道線性布局中的布局重量。 我可以在相對布局中指定布局權重。
示例:布局中的兩個圖像視圖以60:40的比例填充布局。 第一張圖像應占整個屏幕高度的60%,第二張圖像必須占據屏幕剩余的40%。
不要單獨回答這個示例問題,請准確地告訴我這個概念,或者在相對布局中發布一些關於布局權重的參考鏈接。 提前致謝。
您可以在布局的中心放置一個不可見的視圖,並左右對齊您的視圖。 這是一個例子
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/view"
android:background="#fffba2" />
<View
android:id="@+id/view"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_centerHorizontal="true"
android:visibility="invisible" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/view"
android:background="#ba2fff" />
</RelativeLayout>
相對布局不需要權重。 您可以移動圖像視圖以確保它們的比例正確。 權重僅與LinearLayout一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.