但我只能得到这个:
如你所见,我遇到了几个问题.
>虽然我添加了自定义箭头,但我仍然看到了原始箭头.
>我的自定义箭头显示在每一行.
>如何调整自定义箭头的尺寸和布局位置?
>如何生成带下划线的行?
这是我的代码:
onCreateVIEw():
Spinner spinner = (Spinner) rootVIEw.findVIEwByID(R.ID.spinner);this.arraySpinner = new String[]{ "Seleziona una data","03 Agosto 2015","13 Giugno 2015","27 Novembre 2015","30 Dicembre 2015",};ArrayAdapter<String> adapter = new ArrayAdapter<>( getActivity(),R.layout.row_spinner,R.ID.weekofday,arraySpinner);spinner.setAdapter(adapter);
RES /布局/ row_spinner.xml:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:orIEntation="horizontal" androID:padding="8dp"> <TextVIEw androID:ID="@+ID/weekofday" androID:singleline="true" androID:textSize="@dimen/textSize" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content"/> <ImageVIEw androID:ID="@+ID/icon" androID:paddingStart="8dp" androID:paddingleft="8dp" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/spinner_arrow"/></linearLayout>
EDIT
我删除了ImageVIEw并从Resource添加了第二个Spinnercreated:
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromresource( getActivity(),R.array.date,R.layout.spinner_layout);spinnerDate.setAdapter(adapter);Spinner spinnerTime = (Spinner) rootVIEw.findVIEwByID(R.ID.spinnerTime);ArrayAdapter<CharSequence> adapterTime = ArrayAdapter.createFromresource( getActivity(),R.array.ore,R.layout.spinner_layout);spinnerTime.setAdapter(adapterTime);
这个布局:
<TextVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@androID:ID/text1" androID:padding="8dp" androID:singleline="true" androID:layout_height="wrap_content" androID:layout_wIDth="match_parent"/>
我已经将它添加到我的style.xml中:
<style name="Apptheme" parent="@style/_Apptheme"/><!-- Base application theme. --><style name="_Apptheme" parent="theme.AppCompat.light.NoActionbar"> <item name="androID:dropDownSpinnerStyle">@style/Spinnertheme </item> <item name="androID:windowActionbarOverlay">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item></style>........ ....<!--Spinner styles 2--><style name="Spinnertheme" parent="androID:Widget.Spinner"> <item name="androID:background">@drawable/apptheme_spinner_background_holo_light</item> <item name="androID:dropDownSelector">@drawable/apptheme_List_selector_holo_light</item></style><style name="Spinnertheme.DropDown"> <item name="androID:spinnerMode">dropdown</item></style><!-- Changes the spinner drop down item radio button style --><style name="DropDownItemSpinnertheme" parent="androID:Widget.DropDownItem.Spinner"> <item name="androID:checkmark">@drawable/apptheme_btn_radio_holo_light</item></style><style name="ListVIEwSpinnertheme" parent="androID:Widget.ListVIEw"> <item name="androID:ListSelector">@drawable/apptheme_List_selector_holo_light</item></style><style name="ListVIEwSpinnertheme.White" parent="androID:Widget.ListVIEw.White"> <item name="androID:ListSelector">@drawable/apptheme_List_selector_holo_light</item></style><style name="SpinnerItemtheme" parent="androID:TextAppearance.Widget.TextVIEw.SpinnerItem"> <item name="androID:textcolor">#000000</item></style>
但是没有结果!我仍然看到这个:
EDIT 2
我已将style.xml更改为:
http://pastie.org/private/es40xgebcajajltksyeow
这就是我得到的:
现在,我没有更换下拉箭头图标,我甚至还有第二个图标,全息复选框(效果很好,当我选择一个项目时选中),但是,我怎么才能得到我想要的那个?
manifest.xml文件:
http://pastie.org/private/tu0izusbvvxe91lwmh9vnw
解决方法 您必须将ImagevIEw删除到自定义布局row_spinner.xml中.如果您不需要在自定义布局中创建一个箭头,因为如果这样做,它将在每一行中创建,就像发生在您身上一样.为了实现同样的目的,您必须将Spinner样式更改为styles.xml.例如:
<resources> <style name="Spinnertheme" parent="androID:Widget.Spinner"> <item name="androID:background">@drawable/spinner_background_holo_light</item> <item name="androID:dropDownSelector">@drawable/List_selector_holo_light</item> </style> <style name="Spinnertheme.DropDown"> <item name="androID:spinnerMode">dropdown</item> </style> <!-- Changes the spinner drop down item radio button style --> <style name="DropDownItemSpinnertheme" parent="androID:Widget.DropDownItem.Spinner"> <item name="androID:checkmark">@drawable/btn_radio_holo_light</item> </style> <style name="ListVIEwSpinnertheme" parent="androID:Widget.ListVIEw"> <item name="androID:ListSelector">@drawable/List_selector_holo_light</item> </style> <style name="ListVIEwSpinnertheme.White" parent="androID:Widget.ListVIEw.White"> <item name="androID:ListSelector">@drawable/List_selector_holo_light</item> </style> <style name="SpinnerItemtheme" parent="androID:TextAppearance.Widget.TextVIEw.SpinnerItem"> <item name="androID:textcolor">#000000</item> </style></resources>
有关详细信息,请查看:http://androidopentutorials.com/android-how-to-get-holo-spinner-theme-in-android-2-x/
EDIT
selector_spinner.xml:
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <item> <@R_239_3419@> <item> <shape> <gradIEnt androID:angle="90" androID:endcolor="#ffffff" androID:startcolor="#ffffff" androID:type="linear" /> <stroke androID:wIDth="1dp" androID:color="#504a4b" /> <corners androID:radius="5dp" /> <padding androID:bottom="3dp" androID:left="3dp" androID:right="3dp" androID:top="3dp" /> </shape> </item> <item> <bitmap androID:gravity="bottom|right" androID:src="@androID:drawable/arrow_up_float" /> </item> </@R_239_3419@> </item></selector>
styles.xml:
<resources> <!-- Base application theme. --> <style name="Apptheme" parent="androID:theme.Holo.light.DarkActionbar"> <item name="androID:spinnerStyle">@style/Spinnertheme</item> </style> <style name="Spinnertheme" parent="androID:Widget.Spinner"> <item name="androID:background">@drawable/selector_spinner</item> </style></resources>
最后,微调器看起来像
EDIT 2
以下代码进入details_fragment_three.xml
<Spinner androID:ID="@+ID/spinnerDate" androID:layout_marginleft="-8dp" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="@drawable/spinner_item_drawable"/>总结
以上是内存溢出为你收集整理的android – Spinner下拉箭头全部内容,希望文章能够帮你解决android – Spinner下拉箭头所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)