【发布时间】:2015-03-17 10:29:14
【问题描述】:
我为我的列表行创建了这个布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/press_event" >
<LinearLayout
android:id="@+id/viewNameM"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/orange_button_pressed" >
<TextView
android:id="@+id/nameUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#f6911e"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="@+id/viewDetails1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/viewNameM"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/catUser"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/catUser"
android:contentDescription="@string/arrowS"
android:src="@drawable/arrow" />
<TextView
android:id="@+id/catUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<RatingBar
android:id="@+id/ratingUser"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/arrow"
android:layout_marginRight="20dp"
android:layout_marginBottom="3dp"
android:layout_alignBottom="@+id/catUser"
android:indeterminate="false"
android:isIndicator="true"
android:numStars="@integer/five"
android:stepSize="0.1" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/viewDetails2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/viewDetails1"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<TextView
android:id="@+id/cityUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textStyle="bold"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
这是输出:
我想将箭头保留在行的右侧,但我想将它设置在中间,如下所示:
我尝试了几次,但我无法达到我的目标。怎么做? 提前谢谢你。
【问题讨论】:
标签: android xml alignment rows android-relativelayout