Spinner с пользовательским фоном и с треугольником - PullRequest
0 голосов
/ 09 сентября 2018

Android 6.0+, Java 1.8. В моем приложении для Android.

Вот мой пользовательский макет xml:

        <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:binding="http://www.gueei.com/android-binding/"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/containerAmount"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_margin="16dp" >

            <EditText
                android:id="@+id/send_editAmount"
                android:layout_width="0dip"
                android:layout_height="40dip"
                android:layout_weight="0.7"
                android:background="@drawable/backwithborder_notfocus"
                binding:text="amount" >
            </EditText>

            <View
                android:layout_width="8dip"
                android:layout_height="wrap_content" />

            <RelativeLayout
                android:id="@+id/rl"
                android:layout_width="0dip"
                android:layout_height="40dip"
                android:layout_weight="0.3"
                android:background="@drawable/backwithborder_notfocus" >

                <Spinner
                    android:id="@+id/currencySpinner"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </RelativeLayout>
        </LinearLayout>

        </LinearLayout>
</LinearLayout>

Здесь мой пользовательский рисунок backwithborder_notfocus.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <!-- background color -->
    <solid android:color="#FAFAF8" />

    <stroke
        android:width="1dip"
        android:color="#CCCCCC" />

</shape>

А вот результат на Android 6.0

enter image description here

Как видите, треугольник не в углу. Также есть еще одна нижняя строка. Как я могу это исправить? Редактировать текст имеет тот же фон.

Ответы [ 2 ]

0 голосов
/ 09 сентября 2018

Я нашел решение:

    <RelativeLayout
        android:id="@+id/rl"
        android:layout_width="0dip"
        android:layout_height="40dip"
        android:layout_weight="0.3"
        android:background="@drawable/racommon_backwithborder_notfocus" >

    <Spinner
        android:id="@+id/currencySpinner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@null" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_action_popup" />
</RelativeLayout>

А теперь, как я хочу:

enter image description here

0 голосов
/ 09 сентября 2018

Решение:

Изменить это:

 <Spinner
     android:id="@+id/currencySpinner"
     android:layout_width="wrap_content"
     android:layout_height="match_parent" />

Кому:

<Spinner
     android:id="@+id/currencySpinner"
     android:layout_width="match_parent"
     android:layout_height="match_parent" />

Надеюсь, это поможет.

...