0
我有一个RelativeLayout
。它里面我有:如何在其他布局之间放置布局在RelativeLayout中?
- an
ImageView
120x120 dp在右边。在左其他 - 3个布局:
- 1布局(称为顶部)具有
alignParentTop=true
- 第二个布局(称为底部)具有
alignParentBottom=true
- 第三布局(称为中东)是在中间(低于顶部及以上底部)。
- 1布局(称为顶部)具有
的问题是:如果我的容器(RelativeLayout
)设置layout_width="wrap_content"
,我没有看到中东布局。
如果我将它设置为一些值(例如:144dp
),我会看到中间布局。
这里是布局结构(我隐藏了一些子布局,只显示主布局)。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<LinearLayout
android:id="@+id/top"
android:background="#eeaaee"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
android:background="#22eeaa"
android:layout_toLeftOf="@+id/image"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="@+id/middle"
android:layout_width="match_parent"
android:background="#44ee22"
android:layout_toLeftOf="@+id/image"
android:layout_height="64dp"
android:layout_below="@+id/top"
android:layout_above="@+id/bottom">
<TextView
android:id="@+id/hotnews_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="14sp"
/>
</LinearLayout>
<ImageView
android:id="@+id/image"
android:layout_alignParentEnd="true"
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleType="centerCrop"/>
</RelativeLayout>
也许我不明白你的问题,在你的中间布局中试试android:layout_alignParentLeft =“true”。希望能帮助到你。 –
@AndreaEbano它不起作用。 – TOP
你可以设置高度为match_parent –