Выровняйте текст Spinner правильно - PullRequest
0 голосов
/ 19 апреля 2019

Я пытаюсь сделать SearchableSpinner правильное выравнивание текста

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="15dp"
            android:layout_marginLeft="15dp"
            android:orientation="vertical">
            <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                android:id="@+id/statespinner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                app:hintText="Please Select your State"
                android:padding="4dp"
                android:layout_marginBottom="6dp"
                />
            <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                android:id="@+id/districtspinner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                app:hintText="Please Select your District"
                android:padding="4dp"
                android:layout_marginBottom="6dp" />
            <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                android:id="@+id/assemblyspinner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                app:hintText="Please Select your Assembly Constituency"
                android:layout_marginBottom="6dp"
                android:padding="4dp"
                />
            <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                android:id="@+id/wardspinner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                app:hintText="Please Select your Ward"
                android:layout_marginBottom="6dp"
                android:padding="4dp"
               />
</LinearLayout>

Результат последнего кода:

Result

Как вы можете видеть, когда я выбираю любое состояние, оно переходит в левую часть Spinner. Я хочу, чтобы подобное выравнивалось с невыбранными полями.

1 Ответ

2 голосов
/ 19 апреля 2019

Если вы используете TextView в пользовательском макете для отображения выпадающего элемента в счетчике, то вам необходимо добавить некоторые отступы к этому TextView.

Что-то вроде:

spinner_item.xml

(в зависимости от того, что применимо)

<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:background="#b3e2ff"
/>

или

(заполнение со всех сторон)

<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp" />

Дайте мне знать, если вам нужна дополнительная помощь.

...