我activity_choose_number1.xml如何将android中checkedTextView的复选框和文本居中?
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_choose_number1" />
这是content_choose_number1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<ListView
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" />
</LinearLayout>
这是secnumsinglechoice.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
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,但我想在这里尝试更多的代码。
请帮助。谢谢。
我不知道你是什么意思“我想与更多的代码来这里尝试”,但你尝试了'gravity'属性?例如,'android:gravity =“center_horizontal”'? –
为什么不单独使用checkbox和textview?尝试使用'CheckedTextView'很难对齐复选框和文本.. –
@MikeM。是的,尽管我仍然没有工作。 – user3705478