2017-06-17 74 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>