如何使梯度完全像这些在android中绘制
注意:更新问题 我想做一个如图中所述的结尾 中间的灰色是一条线,我希望它与左右两边合并 已尝试解决方案 我找不到更多关于我需要的定制可拉伸渐变的信息如何使梯度完全像这些在android中绘制,android,android-layout,android-custom-view,drawable,android-drawable,Android,Android Layout,Android Custom View,Drawable,Android Drawable,注意:更新问题 我想做一个如图中所述的结尾 中间的灰色是一条线,我希望它与左右两边合并 已尝试解决方案 我找不到更多关于我需要的定制可拉伸渐变的信息 我有这两个图像,并希望使他们与可绘制 提前谢谢 PS:我也尝试了我对我的问题的答案,但我认为这个梯度是不可能的,我已经等了3个月的解决方案。试试这个,然后改变你想要的颜色 android:background:"@drawable/color_grad" color_grad.xml <shape xmlns:android="h
我有这两个图像,并希望使他们与可绘制
提前谢谢
PS:我也尝试了我对我的问题的答案,但我认为这个梯度是不可能的,我已经等了3个月的解决方案。试试这个,然后改变你想要的颜色
android:background:"@drawable/color_grad"
color_grad.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerColor="#FAFAFA"
android:endColor="#C7C7C7"
android:startColor="#C7C7C7"
android:type="linear"
android:angle="270"/>
<corners android:radius="0dp" />
android:background:“@drawable/color\u grad”
color_grad.xml
android:background=“@drawable/gradient”
尝试将类型用作径向:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<size
android:width="48dip"
android:height="48dip" />
<gradient
android:centerColor="@android:color/white"
android:centerY="0.5"
android:gradientRadius="180"
android:type="radial"
android:useLevel="false" />
</shape>
试试看,这对我的要求没有用,还是一样,我想要0角度试试改变尾色和起始色高度和重量缩小尺寸我只试过this@AtifAfridi不是身高和体重,尝试使用android:type=“radial”。只需将上面的代码粘贴到studio中并查看预览。我想这就是你想要的我也试过了。。但不是我想要的。。我希望所有的东西都是垂直的。。右n左为灰色n中心为b白色,但与右/左灰色合并,但垂直形成白色线条
android:background="@drawable/gradient"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#C3C3C3"
android:endColor="#00000000"
android:angle="45"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<size
android:width="48dip"
android:height="48dip" />
<gradient
android:centerColor="@android:color/white"
android:centerY="0.5"
android:gradientRadius="180"
android:type="radial"
android:useLevel="false" />
</shape>