我正在尝试将有光泽的 xml 可绘制渐变作为布局的背景。我已经在使用开始颜色和结束颜色无聊的线性渐变。
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#242424"
android:endColor="#4e4e4e"
android:type="linear" />
</shape>
</item>
有什么办法可以控制它的流量范围吗?请有人帮忙。
已编辑:
好的,我已经做了一些绕过的方法来获得一个漂亮的有光泽的标题栏,
Linear Layout (with a gradation - drawable background, specifying all the start and end color values separately) Over this are the icons, (I used Image buttons with transparent BG), and over this another Relative Layout (with may be a drawable gradient or a fixed, grey color - for glossiness - android:background="#20f0f0f0" ) Here 20 is defining the Alpha value.
P.S,这可能不是一个正确的解决方法,但我对此很满意,因为与 9 个补丁 PNG 文件相比,根据客户需要切换主题要快得多(嘿,顺便说一句,这只是我的看法)
还有这个link在这方面提供了很多信息,
最佳答案
您无法控制其流动范围,但可以使用另一个属性 centerColor。 对于有光泽的背景,您应该尝试渐变中的中心颜色属性。
我在我的应用程序中使用了它。
<gradient
android:startColor="#FFF7F7F7"
android:centerColor="#FFCECFCE"
android:endColor="#FFBEBEBE"
android:angle="270"/>
希望这对你有用
关于android - 带有 android drawable xml 的光泽渐变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8212506/