Android 姜饼版设备中背景色调不变的晶圆厂颜色
在为FAB更改xml中的backgroundTint颜色时,我遇到了一个问题,即该颜色尚未指定给具有姜饼版本的设备。我真的很困惑,不知道为什么它会表现得很奇怪。我完全被这个问题困住了,几个小时后我就找到了解决方案,但我做不到。请帮助我与您的提示和建议,以解决我的问题。我将发布我的代码和问题的屏幕截图,供您参考。提前谢谢 包含_fab.xmlAndroid 姜饼版设备中背景色调不变的晶圆厂颜色,android,material-design,android-2.3-gingerbread,floating-action-button,androiddesignsupport,Android,Material Design,Android 2.3 Gingerbread,Floating Action Button,Androiddesignsupport,在为FAB更改xml中的backgroundTint颜色时,我遇到了一个问题,即该颜色尚未指定给具有姜饼版本的设备。我真的很困惑,不知道为什么它会表现得很奇怪。我完全被这个问题困住了,几个小时后我就找到了解决方案,但我做不到。请帮助我与您的提示和建议,以解决我的问题。我将发布我的代码和问题的屏幕截图,供您参考。提前谢谢 包含_fab.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
app:backgroundTint="#FF0000"
app:borderWidth="0dp"
app:elevation="5dp"
app:fabSize="normal"/>
姜饼和KitKat版本的屏幕截图
注意:我得到的是姜饼装置以上所需的精确输出。问题只出现在姜饼上
它可能会起作用
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FloatingActionButton v = (FloatingActionButton) findViewById(R.id.fab);
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xffff0000});
v.setSupportBackgroundTintList(csl);
}
这实际上是库中的一个bug。您可以看到一个开放的bug报告。我也有类似的问题,它也会导致崩溃。你在使用Genymotion吗?两者都使用,但我没有在Genymotion中尝试。我没有Genymotion姜饼版本,但它在Genymotion的最新版本中运行良好。我只在gingerbread Genymotion上注意到了这一点,不知道这是否是Genymotion的问题。不,设备中也存在此问题。谢谢。我会检查并让你know@Chandru这对你有用吗?如果是,请接受答案,以便其他人得到正确答案,询问你是否有任何疑问。:)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FloatingActionButton v = (FloatingActionButton) findViewById(R.id.fab);
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xffff0000});
v.setSupportBackgroundTintList(csl);
}