Android 透明黑色渐变形状可绘制颜色代码
Android 透明黑色渐变形状可绘制颜色代码,android,gradient,shape,android-drawable,Android,Gradient,Shape,Android Drawable,这是我尝试过的代码,但结果是纯黑色。试试这个: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#000" android:centerColor="#00000000" android:
这是我尝试过的代码,但结果是纯黑色。试试这个:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#000"
android:centerColor="#00000000"
android:endColor="#000"
android:angle="270"
android:dither="true"
/>
</shape>
这个梯度怎么样?顶部为完全透明,底部为50%透明黑色
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#00000000"
android:endColor="#FF000000"
android:angle="270"
android:dither="true"
/>
</shape>
将您的类添加到此代码中
GradientDrawable gd=新的GradientDrawable(
GradientDrawable.Orientation.TOP\u-BOTTOM,
新的int[]{endColor,startColor});
gd.设置转弯半径(0f);
布局。立根式地面牵引(gd)代码>
希望这会有帮助
在我的例子中,它非常有效:
你错丢了巴特勒。显然有人没有!scoff scoff只需将endColor中的FF更改为任何alpha值Yup,,tatz d我正在寻找的值。@MD很高兴它帮助了您!;)你太棒了。我在找it@NaveedAhmad谢谢,非常感谢!
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#00000000"
android:endColor="#80000000"
android:angle="270"
android:dither="true"
/>
</shape>
In my case it works great:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="@android:color/transparent"
android:startColor="#000000" />
</shape>