26h*_*mkk 5 android button rippledrawable android-5.0-lollipop
我使用XML在android 5.0中成功创建了一个涟漪按钮.我的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- the flat button to be used in app -->
<!-- define the ripple -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<!-- the ripple object -->
<item android:id="@android:id/mask">
<!-- button shape (w/ radius) -->
<shape android:shape="rectangle">
<!-- radius of vertices -->
<corners
android:topLeftRadius="7dp"
android:topRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp" />
<!-- color accent (not working) -->
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
我的按钮有问题:按钮的背景颜色不会改变.我也尝试过:
<solid android:color="#0000ff" />
Run Code Online (Sandbox Code Playgroud)
背景仍然保持透明(colorAccent也不起作用).
如果没有通过,我应该如何将矩形(按钮的)背景设置为蓝色
<solid/>
Run Code Online (Sandbox Code Playgroud)
属性?
谢谢
使用@android:id/mask标识符将图层设置为蒙版,仅用于剪切边界并且不绘制.删除id属性应该可以为您提供所需内容.此外,android:radius如果角落的半径相同,则可以使用该属性.
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item>
<shape android:shape="rectangle">
<corners android:radius="7dp" />
<solid android:color="?android:attr/colorAccent" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4855 次 |
| 最近记录: |