【问题标题】:Android Make transparent half of viewAndroid 使视图的一半透明
【发布时间】:2014-01-27 12:38:22
【问题描述】:

我可以使用 android xml 和位图重复制作像“1”这样的图像按钮。

但我想用 android xml 使它像“2”(半透明)。我怎样才能做到?

【问题讨论】:

  • 你可以在按钮背景中使用图片...
  • 你知道Android中的渐变和形状吗?
  • 是的,我知道渐变和形状。但我会做什么?如果我想要它有条纹。link

标签: android xml image transparent


【解决方案1】:

如下创建half_transparent_bg.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
    android:angle="180"
    android:endColor="#00ffffff"
    android:startColor="#ffffffff"/>
</shape>

您可以将图像按钮的背景更改为此可绘制对象

或者如果你想将它堆叠到位图上,重复将具有上面可绘制形状的位图放在图层列表中

编辑:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
    <bitmap
        android:src="@drawable/close"
        android:tileMode="repeat" />
</item>
<item>
    <shape>
        <gradient
            android:angle="180"
            android:endColor="#00ffffff"
            android:startColor="#ffffffff" />
    </shape>
</item>

你可以把你的红色条纹放在哪里而不是靠近

【讨论】:

  • 没关系。但我怎么办?如果我想要它有条纹。link
  • 谢谢你。但我认为我的问题很复杂
【解决方案2】:

这是我的项目视图。 我想去除纯白色并保留白色条带。 透明条的一半。

http://i.stack.imgur.com/H5vJi.png

我是我的xml:

<?xml version="1.0" encoding="utf-8"?>

<item>
    <shape>
        <gradient
            android:angle="0"
            android:endColor="#FFFFFFFF"
            android:startColor="#00FFFFFF" />
    </shape>
</item>
<item>
    <bitmap
        android:antialias="true"
        android:dither="true"
        android:filter="true"
        android:src="@drawable/ww"
        android:tileMode="repeat" >
        <shape>
        </shape>
    </bitmap>
</item>

【讨论】:

  • 这是我进入安卓的第一步。帮我做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-01-19
  • 2015-12-25
  • 2012-02-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多