android - 带有 android drawable xml 的光泽渐变

标签 android android-layout drawable xml-drawable

我正在尝试将有光泽的 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/

相关文章:

android - 蓝牙 Gatt 回调不适用于 Lollipop 的新 API

java - 如何在 CollapsingToolbarLayout 内设置 Toolbar 的重力?

android - picasso 什么时候刷新图像缓存

Android 背景选择器对其 View 外的触摸使用react

java - 设置进度条不确定 srcCompat

java - 一段时间后AsyncTask setMessage android java

java - Android 工作线程卡住主线程

Android - 创建自定义 SearchView

android - Drawable setState 返回 true 但不改变外观

android-studio - 在Android Studio中显示所有可绘制内容