为什么这个布局似乎与我作为属性放置的内容相反?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="600dp"
android:layout_height="600dp" >
<LinearLayout
android:id="@+id/top_left"
android:layout_width="400dp"
android:layout_height="200dp"
android:layout_alignParentTop="true"
>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/green”
/>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="400dp"
android:layout_alignRight="@id/top_left"
>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red"
/>
</LinearLayout>
</RelativeLayout>
我期待它会是这样的:
_____400_________200__
| | |
200 top_left | |400
|______________| |
| |
| |
| |
|______|
但我得到:
最佳答案
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="horizontal" >
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="0.4"
android:background="#00FF00" />
<View
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_weight="0.6"
android:background="#FF0000" />
</LinearLayout>
关于java - 尽管有属性,为什么布局却以相反的方式放置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29342938/