Android 安卓径向梯度
我有以下可绘制设置作为线性布局背景:Android 安卓径向梯度,android,background,drawable,gradient,radial,Android,Background,Drawable,Gradient,Radial,我有以下可绘制设置作为线性布局背景: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <bitmap android:tileMode="repeat" android:dither="true"
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:tileMode="repeat"
android:dither="true"
android:src="@drawable/bg"/>
</item>
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#ffff0000"
android:endColor="#ff00ff00"
android:centerX="50%"
android:centerY="50%"
android:gradientRadius="50%"
android:type="radial"/>
</shape>
</item>
</layer-list>
根据,gradientRadius可以设置为窗口/父级大小的百分比。不幸的是。。。它不起作用了。半径为0。我做错了什么?或者安卓有什么问题
我需要径向梯度来填充整个屏幕。解决方法是什么?如果我很了解您需要什么,您必须制作可绘制的参考布局 (“匹配父母”) 详情如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/"your drawable xml name">
有点晚,但根据文档,您必须设置“50%p”,而不是“50%”。
(请注意表示“父级”的“p”)我指的是布局,也指文本视图。它填充了整个屏幕,可能我不理解您需要什么。我从来都无法获得一个非整数值作为半径。我发现的所有例子都是以像素为单位的,甚至不以倾角为单位。作为一种解决方法,您可以创建可绘制的代码,并在测量视图后设置半径。不适用于我。它总是需要1倍的底部宽度。所以500%[p]给了我5px的半径