當我有兩個視圖在同一個「行」,一個寬度=「fill_parent」時,Android如何計算視圖的大小?Android RelativeLayout和childs with layout_width =「match_parent」
例子:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<EditText
android:id="@+id/EditText01"
android:hint="Enter some text..."
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_toLeftOf="@+id/Button01"
android:layout_height="wrap_content"></EditText>
<Button
android:id="@+id/Button01"
android:text="Press Here!"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"></Button>
</RelativeLayout>
這個代碼給所有自由空間的EditText並顯示按鈕,他的權利。但有了這個改變的EditText填滿了所有寬度和按鍵在屏幕的:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<EditText
android:id="@+id/EditText01"
android:hint="Enter some text..."
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"></EditText>
<Button
android:id="@+id/Button01"
android:text="Press Here!"
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/EditText01"
android:layout_height="wrap_content"></Button>
</RelativeLayout
謝謝,現在我明白了。我不能投票給你:( – juan 2013-05-14 20:17:12
在未來,你可以回來和upvote :),不客氣 – TronicZomB 2013-05-14 20:18:54