我有以下xml实现。但是,正如您在下面看到的,高度和宽度是硬编码的,即使该值适用于Nexus 10.但它在Nexus 7上无法正常工作。相应地调整视图高度和宽度
我需要知道是否有办法处理它有点像百分比?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainView"
android:background="#0000FF">
<View
android:layout_width="220dp"
android:layout_height="wrap_content"
android:id="@+id/view1"
android:background="#000000"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" />
<View
android:layout_width="wrap_content"
android:layout_height="360dp"
android:id="@+id/view2"
android:background="#00FF0000"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_below="@id/view2"
android:id="@+id/view3"
android:background="#000000"
android:layout_alignLeft="@id/view2"
android:layout_alignParentRight="true">
<View
android:layout_width="wrap_content"
android:layout_height="360dp"
android:layout_toRightOf="@id/view1"
android:id="@+id/view4"
android:background="#00FF0000"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout
这里的布局设计
,我不想RelativeLayout的转换为线性布局,因为我对view2
和view 4
顶部添加透明观点的理由接收手势事件。
使用布局权重Linera称布局 – 3xplore
我已经查看和线性布局。 – mystackoverflow