我想使按钮具有不同颜色的环形状。我做到了,它正在设备上进行调试。 代码black_round_button.xml位于绘制-V21形状项目不适用于某些设备上的按钮
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring">
<solid android:color="@color/black" />
按钮的代码是
<Button
android:id="@+id/button31"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/black_round_button"
android:onClick="countClick"
android:text="@string/zero" />
而上件,其中,我调试(安卓5.0.2),它看起来不错: black ring shape
但是!!!当我在其他设备(Android 4.4.4,Android 5.1,其他)上开始调试时,我发现任何形状环都不起作用。它看起来像: no black ring shape
所以,我不知道为什么会发生这种情况。昨天我在5个不同的设备上测试它(其中3个是虚拟的,2个是真实的),只有在我的设备上它按照我的预期工作。
aha,是的,当我问这个问题时,我也开始考虑这个问题。问题在我的Android工作室中,我把它们放在drawable文件夹中,但在github上,它们在drawable-v21中。好的,谢谢你的建议,今天将尝试这个解决方案。 –
好的,祝你好运!消息我,如果它是成功的:) – jdstaerk
你不会相信我,但它并没有帮助=(我把我所有的xml形状从drawable-v21移动到了可绘制的,没有任何东西。 看起来我需要使用gradle和build bersions –