将复选框与ListView项的中心对齐 [英] Align Checkbox to center of the ListView item
本文介绍了将复选框与ListView项的中心对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序使用以下布局显示剪辑列表.
The following layout is used in my app to show cliplists.
<?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="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/ClipNo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Clip No"
android:textSize="20sp"
android:gravity="center"
android:layout_weight="1"/>
<TextView
android:id="@+id/ClipTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Time"
android:textSize="20sp"
android:gravity="center"
android:layout_weight="1"/>
<TextView
android:id="@+id/ClipDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:textSize="20sp"
android:gravity="center"
android:layout_weight="1"/>
<CheckBox android:id="@+id/ClipMark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" />
</LinearLayout>
下图显示了布局的输出
我如何将复选框"排列在标记"标题的中心
预先感谢
推荐答案
因为您已添加android:layout_weight="1"
更改您的以下代码
<CheckBox
android:id="@+id/ClipMark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" />
收件人
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<CheckBox
android:id="@+id/ClipMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
这篇关于将复选框与ListView项的中心对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文