2017-06-17 7 views
0

私は完璧に動作するスピナーをデザイン問題にしました。 私のスピナーコードはスピナー arroundの図示していないAndroid Spinnerの国境問題

<Spinner 
     android:id="@+id/product" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:drawable="@drawable/border" 
     android:padding="25dp"> 
    </Spinner> 

Javaコード

描画可能/国境コード@
spinnerShop = (Spinner) myView.findViewById(R.id.shop); 
/*Shop Spinner*/ 
ArrayAdapter<CharSequence> shopArray = ArrayAdapter.createFromResource(getActivity(), 
     R.array.shopArray, android.R.layout.simple_list_item_1); 
shopArray.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
spinnerShop.setAdapter(shopArray); 

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
<corners 
    android:radius="2dp" /> 
<solid android:color="@color/colorText" /> 
<stroke 
     android:width="1dip" 
     android:color="@color/colorPrimary"/> 
</shape> 

ボーダーである enter image description here

答えて

1

スピナーのstyle.xmlファイルにカスタムスタイルを定義する必要があります。次に、以下のように、あなたのスピナーに、このカスタムスタイルを与える:あなたは、以下のようstyle.xmlファイルにyour_custom_spinner_styleであなたの@描画可能/ border_codeを使用します

<Spinner 
    android:id="@+id/product" 
    style="@style/your_custom_spinner_style" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="25dp"/> 

<style name="your_custom_spinner_style">   
      <item name="android:background">@drawable/border_code</item> 
      ........ 
    </style> 

した後にお知らせ下さいそれを試してみてください。

+0

境界線は表示されますが、矢印は表示されません。 –

1
<Spinner 
    android:id="@+id/product" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:drawable="@drawable/border" // replace this line 
    android:background="@drawable/border" // with this 
    android:padding="25dp"> 
</Spinner> 
画像を表示