android 复选框 textview,如何将android中checkedTextView的复选框和文本居中?

"博客作者在尝试使Android应用中的`CheckedTextView`的复选框和文本居中对齐时遇到困难。已尝试过设置`drawableLeft`、`textAlignment="center"`等方法,但未能实现理想效果。寻求解决方案,尤其是关于`gravity`属性的使用建议。"
摘要由CSDN通过智能技术生成

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/AppTheme.AppBarOverlay">

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

这是content_choose_number1.xml

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:gravity="center_horizontal"

android:orientation="horizontal"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:context="com.abc.abc.ChooseNumber1"

tools:showIn="@layout/activity_choose_number1">

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:gravity="center_horizontal"

android:orientation="horizontal"

android:id="@+id/listViewNumberList"

android:choiceMode="singleChoice"

android:divider="@android:color/transparent"

android:dividerHeight="0dp" />

这是secnumsinglechoice.xml

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="match_parent"

android:textAppearance="?android:attr/textAppearanceListItemSmall"

android:checkMark="@null"

android:drawableStart="?android:attr/listChoiceIndicatorSingle"

tools:targetApi="ice_cream_sandwich"

android:textSize="25dp"

android:linksClickable="false"

android:checked="false"

android:paddingTop="20dp"

android:paddingBottom="20dp" />

secnumsinglechoice.xml是android.R.layout.simple_list_item_single_choice的复制粘贴,并进行了一些更改。

现在我需要的是中心对齐secnumusingchoice.xml的复选框和文本。我还需要复选框,留下文字的侧

事情我试过列表视图中的每一项 1)如果我做drawableLeft,它创建文本和复选框之间的空间,但不会使双方为中心 2)如果我添加android:textAlignment =“center”,那么它仍然中心对齐文本,但不是复选框。 3)我在这里尝试center text and checkmark of CheckedTextView,但我想在这里尝试更多的代码。

请帮助。谢谢。

+0

我不知道你是什么意思“我想与更多的代码来这里尝试”,但你尝试了'gravity'属性?例如,'android:gravity =“center_horizo​​ntal”'? –

+0

为什么不单独使用checkbox和textview?尝试使用'CheckedTextView'很难对齐复选框和文本.. –

+0

@MikeM。是的,尽管我仍然没有工作。 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值