2017-04-21 69 views
-3

我使用飞旋在我的布局,其外观如下:Android的微调建议需要

enter image description here

我想增加微调大小,使其更具吸引力和可见。

这里是spinner xml和activity snippet。

<Spinner 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/spinner_room" 
    android:layout_below="@id/Toolbar_Room" 
    android:textSize="52sp" 
    android:prompt="@string/room_prompt" 
    android:spinnerMode="dropdown" 
    android:dropDownSelector="@drawable/img_small_box_green" 
    android:drawSelectorOnTop="true"></Spinner> 
+0

http://stackoverflow.com/questions/17407626/custom-layout-for-spinner-item在这里你去。 – 6155031

回答

0

我创建了带卡片视图的微调框,请检查此设置您可能会喜欢此设计。

enter image description here

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="@dimen/margin_5" 
    android:background="@android:color/white" 
    app:cardElevation="@dimen/margin_2" 
    app:contentPaddingBottom="@dimen/margin_5" 
    app:contentPaddingTop="@dimen/margin_5"> 


    <Spinner 
     android:id="@+id/sp_filter_status" 
     style="@style/Widget.Spinner" 
     android:background="@drawable/spinner_expand_black" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:padding="0dp" /> 

</android.support.v7.widget.CardView> 

绘制/ spinner_expand_black

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 
    <item> 
     <shape> 
      <solid android:color="@android:color/white" /> 

      <padding 
       android:bottom="@dimen/margin_1" 
       android:left="@dimen/margin_1" 
       android:right="@dimen/margin_1" 
       android:top="@dimen/margin_1" /> 
     </shape> 
    </item> 
    <item> 
     <bitmap 
      android:gravity="end" 
      android:src="@mipmap/ic_action_expand_more" /> 
    </item> 
</layer-list> 

@纹理贴图/ ic_action_expand_more是底部的图像箭头可以从材料图标的网站找到。

风格

<style name="Widget.Spinner" parent="Widget.AppCompat.Spinner.DropDown"> 
     <item name="android:background">?android:selectableItemBackground</item> 
     <item name="android:dropDownSelector">?android:selectableItemBackground</item> 
     <item name="android:divider">@null</item> 
     <item name="overlapAnchor">true</item> 
     <item name="android:textColor">@android:color/black</item> 
     <item name="android:textSize">@dimen/text_16</item> 
     <item name="android:focusableInTouchMode">true</item> 
     <item name="android:focusable">true</item> 
    </style>