2012-05-18 28 views
0

enter image description here定製下拉列表用於微調

在上述(片劑橫向模式)圖片,什麼辦法可以最小化Spinner的下拉寬度?或者創建一個自定義下拉菜單?謝謝。

編輯: 我只是使用這個android自己的佈局。 spinner.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);

XML補充:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:layout_margin="5dp" 
     android:weightSum="3"> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Font Size" 
      android:textSize="15sp" 
      /> 
     <Spinner 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      /> 
    </LinearLayout> 
+0

發佈您的代碼片段。以便我們可以幫助您根據它 –

+0

編輯我的文章。 –

+0

我的意思是添加包含定義的微調項目的xml –

回答

0

我認爲問題是,你的線性佈局的寬度設置爲填補父。嘗試替換它來包裝內容。它可能會訣竅。

0

使用此代碼定製微調風格..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
    <TextView 
     android:id="@+id/spinnerTarget" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="8pt"   
     android:textColor="#000000"   
     android:gravity="center"/> 
    <TextView 
     android:layout_marginLeft="5dip" 
     android:id="@+id/subText"    
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
</LinearLayout> 

,這對您的主要佈局微調...

<Spinner 
      android:id="@+id/spinner1" 
      android:layout_width="250dp" 
      android:layout_height="40dp" 
      android:layout_marginLeft="15dp" 
      android:layout_marginRight="15dp" 
      android:prompt="@string/prompt"/> 
相關問題