Android listview上的两个文本视图aligend right
我想在我的listview上有两个文本视图,我想其中一个右对齐,另一个居中对齐,但它们都是左对齐的!!!我的listview xml:Android listview上的两个文本视图aligend right,android,Android,我想在我的listview上有两个文本视图,我想其中一个右对齐,另一个居中对齐,但它们都是左对齐的!!!我的listview xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_he
<?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="vertical">
<TextView
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/tv_subject"
android:layout_weight="0.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_pic"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:contentDescription="ads"/>
<TextView
android:layout_gravity="right"
android:gravity="right"
android:textColor="#ffffff"
android:paddingRight="5dp"
android:layout_weight="0.5"
android:id="@+id/tv_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
这段代码运行成功,但当编译器构建应用程序时,我想在列表视图中触摸一行,事实上,当我的手指在列表视图中时,行的颜色应该改变,但因为我必须设置宽度匹配,所以它覆盖了整个屏幕。
我如何才能使其成为我想要的输出,并且当我的手指位于所选行上时,用户可以看到行的颜色已更改。只需删除
android:background=“#ffffff”
。如果您想更改颜色,请将其设置为ListView。您的问题不是很清楚。你能再解释一下发生了什么和预期会发生什么吗。