开发者

custom UI for drop down

i am in process of making a custom UI for my app, have almost created XML based shapes for all the controls which is开发者_运维问答 fine, but spinner seems to be the main problem, is their any example for making a new shape for spinner, which could be supported on 1.5 to 2.2, i know about a tutorial that tells for custom shape for spinner but that`s for less then 1.5, thanks


Have you managed to do it? I'd suggest you make an XML Drawable like this:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item  android:state_pressed="true"
   android:state_focused="false">
        <shape>
            <solid android:color="#535151" />
            <stroke android:width="1dp" android:color="#000000" />
            <corners android:radius="3dp" />
            <padding android:left="1dp"
                android:top="1dp"
                android:right="1dp"
                android:bottom="1dp" />
        </shape>
 </item>  
</selector>

And then use it as the background for your spinner in the 'main.xml':

<Spinner
 android:background="@drawable/spinner_design"
 android:id="@+id/customSpinner"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"/>

In order to make your spinner design look coherent, you should also make your own <TextView> design for the spinner and use similar background colours for both the <TextView> as well as the XML Drawable Shape.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜