<resources> <style name="Customtheme" parent="MaterialDrawertheme.light.DarkToolbar"> <!-- varIoUs items --> <item name="androID:buttonStyle">@style/buttonStyle</item> </style> <!-- a couple of other styles --> <style name="buttonStyle" parent="androID:style/Widget.button"> <item name="androID:textSize">19sp</item> <item name="androID:textcolor">@color/primaryTextContrast</item> <item name="androID:background">@color/primary</item> </style></resources>
在清单中:
<application androID:name=".CustomApplication" androID:allowBackup="true" androID:icon="@mipmap/ic_launcher" androID:label="@string/application_name" androID:theme="@style/Customtheme">
color / primary是深蓝色,color / primaryTextContrast是白色的.在棒棒糖,按钮看起来完美.在4.1设备上,它是浅灰色的黑色文字.我发现这样做的每个资源看起来都像我在做什么,所以我不知道我在这里失踪了什么.
我也有类似的问题,控制基本样式定义中的文本大小.
更新:这里是颜色.
<resources> <color name="primary">#3F51B5</color> <color name="dark">#303F9F</color> <color name="accent">#FFCA28</color> <color name="background">@androID:color/white</color> <!-- color for text displayed on top of the primary or dark color --> <color name="primaryTextContrast">@androID:color/white</color> <!-- color for text displayed on the background color (which I think will always be white) --> <color name="basicText">@color/primary</color> <!-- color for text displayed on the accent color --> <color name="accentText">#303F9F</color></resources>
这里是v19 / styles.xml:
<?xml version="1.0" enCoding="utf-8"?><resources> <style name="Fullscreentheme" parent="MaterialDrawertheme.light.DarkToolbar.TranslucentStatus"> <item name="androID:windowTranslucentNavigation">true</item> <item name="androID:windowNoTitle">true</item> <item name="androID:windowTranslucentStatus">true</item> </style></resources>
这是v21:
<?xml version="1.0" enCoding="utf-8"?><resources> <style name="Apptheme" parent="Customtheme"> <item name="androID:windowContentTransitions">true</item> <item name="androID:windowAllowEnterTransitionOverlap">true</item> <item name="androID:windowAllowReturnTransitionOverlap">true</item> <item name="androID:windowsharedElementEnterTransition">@androID:Transition/move</item> <item name="androID:windowsharedElementExitTransition">@androID:Transition/move</item> </style></resources>
我不认为这些都是在5.1上正常工作的.
解决方法 使用AppCompat 22.1. (22.2.0也应该工作),我定义了一个这样的样式:<style name="MyApp.button.Red" parent="Base.Widget.AppCompat.button"> <item name="colorbuttonnormal">@color/primary</item> <item name="androID:colorbuttonnormal">@color/primary</item> <item name="androID:textcolor">@androID:color/white</item></style>
然后使用AndroID命名空间中的本机主题属性将主题应用于按钮,如Chris Banes的this令人惊叹的帖子中所述.
<button androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/sign_up_button" androID:theme="@style/MyApp.button.Red" />总结
以上是内存溢出为你收集整理的Android默认按钮样式不工作全部内容,希望文章能够帮你解决Android默认按钮样式不工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)