2017-06-17 65 views
0

我已經使微調工作完美,但設計問題。 我的微調代碼Android微調邊框問題

<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> 

邊境不角落找尋微調 顯示

<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); 

@繪製/邊框代碼顯示圖像 enter image description here

回答

1

您需要在您的微調器的style.xml文件中定義一個自定義樣式。然後,你會給這個自定義樣式到您的微調如下:

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

你會用你的@繪製/ border_code在your_custom_spinner_style在如下style.xml文件:

<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>