我一直在处理一个包含3个textView和一个imageView的布局。所有的一切都应该形成一个正方形。现在看起来是这样的:

我对你的表情很满意。问题在于我的代码,因为视图是用android设置的:布局_边缘化、左/右和顶,如果可能的话,我希望它由android:layout_toLeftOf和toRightOf设置,并在5-10 if左右的所有视图之间留出一个空白。
所以请帮我重写我的代码。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background3"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:contentDescription="@string/app_name"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="100dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:orientation="vertical" >
<ImageView
android:id="@+id/img"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop" />
</RelativeLayout>
<TextView
android:id="@+id/title"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="100dp"
android:background="#90000000"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#E97305"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="@+id/detail"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:layout_marginTop="123dp"
android:textColor="#ffffff"
android:paddingBottom="22dp"/>
<TextView
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:layout_marginRight="5dp"
android:layout_marginTop="185dp"
android:textColor="#ffffff" />
</RelativeLayout>发布于 2014-01-12 12:32:19
你可以试试这个:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background3"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:contentDescription="@string/app_name"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="100dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:orientation="vertical" >
<ImageView
android:id="@+id/img"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop" />
</RelativeLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/relativeLayout2"
android:layout_alignTop="@id/relativeLayout2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@id/relativeLayout2"
android:background="#90000000"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#E97305"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="@+id/detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:paddingBottom="22dp"
android:textColor="#ffffff" />
<TextView
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/detail"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#90000000"
android:cacheColorHint="#00000000"
android:textColor="#ffffff" />
</RelativeLayout>https://stackoverflow.com/questions/21073750
复制相似问题