私は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" />
activity_choose_number1.xmlこれはこれは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" />
ある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は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