我正在制作一个android应用程序,我在对话框模式中使用Spinners,定义如下:
<Spinner android:id="@+id/new_order_address" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/SpinnerTheme" style="@style/UnderlinedSpinner" android:layout_below="@+id/new_order_hint_address" android:prompt="@string/myString" android:spinnerMode="dialog" android:layout_marginBottom="5dp" />风格在哪里
<style name="SpinnerTheme"> <item name="colorControlNormal"> @color/colorPrimaryDark </item> <item name="android:textColorSecondary"> @color/colorPrimaryDark </item> <item name="android:colorControlHighlight"> @color/colorPrimaryDark </item> <item name="android:colorControlActivated"> @color/colorPrimaryDark </item> <item name="android:minHeight"> 35dp </item> <item name="android:showDividers"> middle </item> <item name="android:divider"> @color/colorAccent </item> <item name="android:dividerHeight"> 0.5dp </item> </style> <style name="SpinnerLabel" parent="TextAppearance.Design.Hint"> <item name="android:paddingLeft">@dimen/input_label_horizontal_spacing</item> <item name="android:paddingRight">@dimen/input_label_horizontal_spacing</item> <item name="android:textSize"> 14sp </item> <item name="android:textColor">@color/hintText</item> </style> <style name="UnderlinedSpinner" parent="Base.Widget.AppCompat.Spinner.Underlined"/>在API <23中,一切正常,但在API 23中,不显示提示。 我试过从java代码中设置,我已经阅读了所有类似的问题和答案,并且没有任何运气。
提前致谢
I'm making an android app, and I'm using Spinners in Dialog Mode, defined as follows :
<Spinner android:id="@+id/new_order_address" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/SpinnerTheme" style="@style/UnderlinedSpinner" android:layout_below="@+id/new_order_hint_address" android:prompt="@string/myString" android:spinnerMode="dialog" android:layout_marginBottom="5dp" />where the styles are
<style name="SpinnerTheme"> <item name="colorControlNormal"> @color/colorPrimaryDark </item> <item name="android:textColorSecondary"> @color/colorPrimaryDark </item> <item name="android:colorControlHighlight"> @color/colorPrimaryDark </item> <item name="android:colorControlActivated"> @color/colorPrimaryDark </item> <item name="android:minHeight"> 35dp </item> <item name="android:showDividers"> middle </item> <item name="android:divider"> @color/colorAccent </item> <item name="android:dividerHeight"> 0.5dp </item> </style> <style name="SpinnerLabel" parent="TextAppearance.Design.Hint"> <item name="android:paddingLeft">@dimen/input_label_horizontal_spacing</item> <item name="android:paddingRight">@dimen/input_label_horizontal_spacing</item> <item name="android:textSize"> 14sp </item> <item name="android:textColor">@color/hintText</item> </style> <style name="UnderlinedSpinner" parent="Base.Widget.AppCompat.Spinner.Underlined"/>In API <23, everything works fine, but in API 23, the prompt is not shown. I've tried setting in from the java code, I've read all the similar questions and answers and have had no luck whatsoever.
Thanks in advance
最满意答案
好吧,在经过了很多试验和错误之后,我发现问题是提示文本的颜色与提示的背景颜色相同(都是白色的)。
它背后的原因是继承了“textColorPrimary”,我没有设置微调框的样式,但是我确实按照它所在的Tabhost的样式进行了设置。 它看起来像它继承了这个属性。
因此,解决方案只是将该参数添加到样式中,并使用所需的颜色。
我不确定的唯一原因是这只发生在API> 23,而不是其他。
Ok, after a lot more of trial and error, I found out that the issue was in fact that the color of the prompt text was the same as the color of the background of the prompt (both white).
The reason behind it relays on the "textColorPrimary", which I'm not setting in the style of the spinner, but I did set in the style of the Tabhost where it is located. It looks like it inherited this property.
Therefore, the solution is just adding that parameter to the style, with the color desired.
The only thing I'm not sure is why this only happens in APIs > 23, and not the others.
更多推荐
发布评论