Android のカスタム スピナー スタイル

背景

UI には、次のような視覚的なドロップダウン ボックスが必要です。

 解決策: スピナーの背景画像を次のように設定します。

   <Spinner
                    android:id="@+id/sp_gender"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/shape_gender"
                    android:entries="@array/gender" />

Shape_gender は私が描いた形状です。

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
            <corners android:radius="4dp" />
            <stroke
                android:width="1dp"
                android:color="#C8C8C8"
                />
        </shape>
    </item>
    <item>
        <bitmap
            android:gravity="end"
            android:src="@drawable/icon_user_info_pull"
            />
    </item>
</layer-list>

ここでは特にレイヤーリストについて話したいと思います PhotoShopを勉強したことのある人ならレイヤーの概念を知っています ここでも同様です 一度に1レイヤーずつ描画できます 下に書いたものは上に表示されます。

したがって、丸い角を使用したり、写真を使用して継ぎ合わせたり位置合わせしたりすることができます。

おすすめ

転載: blog.csdn.net/Jason_HD/article/details/121280053#comments_28295591