android - 自定义线性布局

标签 android widget android-linearlayout

我想做如下布局:

enter image description here

为此我需要三个这样的背景:

This is one layout

this is another layout

this is another

我需要把它们全部结合起来

在运行时我必须改变每个的背景颜色

所以我想制作自定义线性布局。

但我不知道如何让它变成那样。

我已经检查了一些制作三角形和平行四边形布局的示例,但我也想合并所有三个 View 。请提供一些有用的链接并提供代码示例而不是提供引用。

在此先感谢您。 :)

我试过相对布局。对于远程 View ,我试过这个:

ColorFilter cf = new PorterDuffColorFilter(-15032095, Mode.MULTIPLY);
        Drawable d= context.getResources().getDrawable(R.drawable.panel1);
        d.mutate();
        d.setColorFilter(cf);

我尝试了以下代码:

rv.setInt(R.id.rl_noti_main, "setColorFilter", d);
rv.setInt(R.id.rl_noti_main, "setBackgroundDrawable", -15032095);
rv.setInt(R.id.rl_noti_main, "setBackgroundResources",d);

最佳答案

尝试框架布局或相对布局。您需要重叠每个 View 才能实现这一点,而这在线性布局中是做不到的。将每个图像制作为具有透明区域的矩形,其中部分需要重叠。

关于android - 自定义线性布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29025795/

相关文章:

android - TextView 在不同的分辨率下具有不同的高度。 DIP 不起作用

java - Android View Canvas onDraw 未执行

ios - 今天查看扩展(小部件)不工作

android - findViewById 返回 null - 为什么?

android - LinearLayout 中的RelativeLayout 无法正确包装内容

java - match_parent 布局参数不起作用?

java - 我的验证全部合一

javascript - 用新构造的 DOM 结构替换小部件元素

php - 如何在 Yii2 中创建可重用的小部件

Android线性布局,如何匹配剩余的父级?