当我有两个视图在同一个“行”,一个宽度=“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