2012-08-31 54 views
4

我有一個微調,看起來像醜陋的極端像這樣: here is my image http://i47.tinypic.com/5n6dj7.png爲什麼我的微調器太可怕了?

當我點擊它看起來更好一點: here is my image http://i50.tinypic.com/653jnk.png

但儘管如此,在默認情況下它甚至沒有模樣一個微調。任何想法我怎麼能改善它的外觀?

下面是代碼:

adapter=new SpinAdapter(this,com.Orange.R.layout.spinnerrowlist,spinnerInfo); 
adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item); 
previousVisitCommentsSpinner.setAdapter(adapter); 

spinnerrowlist.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="5dp" 
    android:background="#FFFFFF" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/textview_spinner1" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingLeft="5dp" 
     android:layout_alignParentLeft="true" 
     android:textColor="@drawable/textorange_selected" /> 

    <TextView 
     android:id="@+id/textview_spinner2" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="5dp" 
     android:layout_toRightOf="@+id/textview_spinner1" 
     android:paddingLeft="5dp" 
     android:textColor="@drawable/textorange_selected" /> 

    <TextView 
     android:id="@+id/textview_spinner3" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:paddingLeft="5dp" 
     android:textColor="@drawable/textorange_selected" /> 

</RelativeLayout> 

這裏是微調:

<Spinner 
    android:id="@+id/previousVisitComments" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_below="@+id/previousvisit" 
    android:layout_marginTop="15dp" 
    android:background="@drawable/spinner_selector" 
    android:textColor="@color/medium_orange" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    /> 

在微調中的項目應該是同一條線,這就是爲什麼我使用horizo口腔佈局! 謝謝你的回答!

+1

關鍵在於com.Orange.R.layout.spinnerrowlist,而不是下拉菜單。現在看不到它;如果我有空,我會試着再看看它,但它試圖將文本壓縮到一個小區域。 – Muz

回答

1

嘗試添加該

android:layout_toRightOf="@+id/textview_spinner1 

,你也可以添加,看它是否有差別

android:layout_below 

以下只是讓我知道如何去:)

1

微調器中的項目應該在同一行上,這就是爲什麼我使用水平佈局!

問題是,您正試圖將很多文本擠入狹窄的區域。然而,你有兩個選擇:

首先使用你有什麼,只需添加layout_toLeftOf屬性textview_spinner2

<TextView 
    android:id="@+id/textview_spinner2" 
    style="?android:attr/spinnerItemStyle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:layout_toLeftOf="@+id/textview_spinner3" 
    android:layout_toRightOf="@+id/textview_spinner1" 
    android:paddingLeft="5dp" /> 

另外你說你正在使用a horizontal layout但RelativeLayout的沒有屬性orientation ,所以此行不做任何事情:

android:orientation="horizontal" 

子元素的組織由個人attribut ES樣:layout_toLeftOflayout_toRightOflayout_above

如果你的RelativeLayout表現在不守規矩的方式,你有一個簡單的佈局像這樣的二,你可以隨時切換到的LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="5dp" > 

    <TextView 
     android:id="@+id/textview_spinner1" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:textColor="@drawable/textorange_selected" /> 

    <TextView 
     android:id="@+id/textview_spinner2" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:paddingLeft="5dp" 
     android:textColor="@drawable/textorange_selected" /> 

    <TextView 
     android:id="@+id/textview_spinner3" 
     style="?android:attr/spinnerItemStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:paddingLeft="5dp" 
     android:textColor="@drawable/textorange_selected" /> 

</LinearLayout> 

現在,您的Spinner中沒有任何列重疊。

+0

我這樣做了,但它不能使它工作!\ – adrian

1

您可以在Java代碼中嘗試(android.R.layout.simple_spinner_dropdown_item)。而不是(com.Orange.R.layout.multiline_spinner_dropdown_item)希望這有助於。

相關問題