Pankaj Kharche
Pankaj Kharche

Reputation: 1329

Style not appyling on Spinner?

enter image description here

In this app, I want to Center item of Spinner. I have tried android:gravity="center", but it is not working? and I have to add small image on spinner. how I do this. please guide me.

in res/layout spinner_layout.xml

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"`
             android:layout_width="fill_parent"
             android:layout_height="match_parent">`
      <Spinner
               android:id="@+id/spinner1"
               android:layout_width="fill_parent"
           android:layout_height="55dp" 
               android:prompt="@string/spinner_promt"
              style="@style/spinnerStyleView"
        />
        </LinearLayout>

style in **style.xml**

        <style name="spinnerStyleView">
              <item name="android:background"> @drawable/notetvbg</item>
              <item name="android:textColor">@android:color/darker_gray</item>
           </style>`

Upvotes: 2

Views: 6731

Answers (1)

XEENA
XEENA

Reputation: 567

Use this code to make style spinner..

drawable/slim_spinner_normal.9.png

enter image description here

drawable/slim_spinner_pressed.9.png

enter image description here

drawable/spinner_back.xml

<?xml version="1.0" encoding="utf-8"?>
        <selector xmlns:android="http://schemas.android.com/apk/res/android">
             <item android:state_pressed="true"
                   android:drawable="@drawable/slim_spinner_pressed" />
             <item android:drawable="@drawable/slim_spinner_normal" />
        </selector>

layout/main.xml

<RelativeLayout
    android:id="@+id/RL_TAG_FRAME"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <Spinner
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/spinner_back.xml" />

</RelativeLayout>

Additional skins

enter image description here enter image description here enter image description here enter image description here enter image description here

Upvotes: 2

Related Questions