android-透明的RelativeLayout [英] android- transparent RelativeLayout

查看:31
本文介绍了android-透明的RelativeLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个具有可绘制渐变背景的活动,并将在其背景上显示 4 个面板 (RelativeLayout).现在我想让 4 个面板透明(例如 50%),以便也可以看到渐变背景.我搜索了谷歌,但我发现只有通过活动而不是布局来做到这一点的方法.如何做我想做的事?

I want to make an activity which has a gradient drawable as background and is going to show 4 panels (RelativeLayout) on top of it's background. now I want to make the 4 panels transparent(e.g. 50%) so that the gradient background could be seen, too. I searched google, but I found only ways to do this with activities not layouts. how to do what I want?

推荐答案

您可以创建带有 shape 内容的 drawable.并将您的风格放入其中.

You can create a drawable with shape content. And put your styles in it.

示例:

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

    <solid android:color="#77ffffff"/>

</shape>

在 res 路径下的 drawable 文件夹中创建一个名为 sampleBackground.xml 的文件.并设置面板的背景属性:

Create a file with a name such as sampleBackground.xml in the drawable folder in the res path. And set the background attribute of your panels to it:

android:background="@drawable/sampleBackground"

这篇关于android-透明的RelativeLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆