我怎样才能让微调宽度相同,最大的可用项目的宽度 [英] How can I make the spinner width same as largest available item width
问题描述
我知道,即使我用 WRAP_CONTENT
我的微调(我避免使用 match_parent
,因为我不希望微调过长),并使用 match_parent
为微调的项目视图和下拉项目视图,
我还是找到微调的宽度不一样大项的宽度
正如你所看到的,来自国家UnitedStates
不是合适的。
所以,如果我选择了来自国家UnitedStates
,只有微调的将调整
我怎样才能使微调调整到最大可用物品的宽度,即使没有明确地选择最大的项目?
我的微调XML是
<微调
机器人:ID =@ + ID / spinner1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =10dp/>
和我的飞旋的看法XML是
< TextView中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / text_view_0
风格=机器人:ATTR / spinnerItemStyle
机器人:单线=真
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:drawablePadding =10dp
机器人:重力=center_vertical/>
< CheckedTextView的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / checked_text_view_0
风格=机器人:ATTR / spinnerDropDownItemStyle
机器人:单线=真
机器人:layout_width =match_parent
机器人:layout_height =48dp
机器人:=了minHeight48dp
机器人:drawablePadding =10dp/>
我仅仅是解决问题,通过使用
<微调
机器人:ID =@ + ID / country_spinner
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:=了minWidth200dp
机器人:layout_marginBottom =10dp/>
200dp只是尝试正误差值,以确保在下拉列表中的所有项目都可见。
I realize even I use wrap_content
for my spinner (I avoid using match_parent
as I do not want the spinner overly long), and using match_parent
for spinner's item view and drop down item view,
I still find the spinner's width is not same as largest item's width
As you can see, the UnitedKingdom
is not fit.
So, if I select the UnitedKingdom
, only the spinner's will resize
How can I make the spinner resize to the largest available item width, even without being explicitly selecting the largest item?
My spinner XML is
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" />
and my spinner's views XML are
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view_0"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:gravity="center_vertical" />
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/checked_text_view_0"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="48dp"
android:minHeight="48dp"
android:drawablePadding="10dp" />
I merely "solve" the problem by using
<Spinner
android:id="@+id/country_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="200dp"
android:layout_marginBottom="10dp" />
200dp is just try-n-error value, to ensure all items in the drop down list are visible.
这篇关于我怎样才能让微调宽度相同,最大的可用项目的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!