Элемент Spinner не находится рядом со стрелкой Spinner - PullRequest
0 голосов
/ 02 мая 2018

У меня есть Spinner :

<Spinner
            android:id="@+id/spinner_puncte_castigatoare_precedente"
            android:layout_weight="1"
            android:textAlignment="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

с ArrayAdapter :

public AdapterSpinner(Context context, int textViewResourceId,
                      List<PuncteCastigatoareGlobalBean> values) {
    super(context, textViewResourceId, values);
    this.context = context;
    this.values = values;
    this.setDropDownViewResource(R.layout.item_spinner_dropdown_puncte_castigatoare);
}

Где R.layout.item_spinner_dropdown_puncte_castigatoare равно:

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/text1"
  style="?android:attr/spinnerDropDownItemStyle"
  android:singleLine="true"
  android:layout_width="match_parent"
  android:layout_height="40dp"
  android:ellipsize="marquee"
  android:textColor="#000000"/>

и int textViewResourceId :

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:textAlignment="viewEnd"
android:layout_gravity="end"
android:layout_height="40dp"
android:ellipsize="marquee"
android:textColor="#000000"/>

Это мой пользовательский интерфейс: enter image description here

Я хочу, чтобы предмет со спиннером был рядом со стрелкой, как я могу это сделать?

1 Ответ

0 голосов
/ 02 мая 2018

в textViewResource у вас есть:
android:textAlignment="viewEnd"
и
android:layout_gravity="end"

Замените их на:
android:gravity="end"

android: gravity означает гравитацию содержимого в пределах представления, тогда как android: layout_gravity означает гравитацию самого представления внутри его родительского макета.

...