自定义线性布局 [英] Custom LinearLayout

查看:24
本文介绍了自定义线性布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做出如下布局:

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

For that i will need three backgrounds like this:

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

I will need to combine all of them and

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

at runtime i have to change background color of each

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

so i thought to make custom linearlayout.

但我不知道如何做到这一点.

But I don't know how to make it like that.

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

I have checked some example of making triangular and parallelogram layout but i want to merge all three views also. Please give some useful links and also give code example rather than giving references.

在此先感谢您.:)

我尝试了相对布局.对于远程视图,我试过这个:

I tried in relative layout. for remoteview, i tried this:

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);

推荐答案

尝试框架布局或相对布局.您需要重叠每个视图来实现这一点,这在线性布局中是无法做到的.将每张图片制作成透明区域的矩形,其中部分需要重叠.

try frame layout or relative layout. you need to overlap each view to achieve this which can't be done in linear layout. make each image as rectangle with transparent area which part need to overlap.

这篇关于自定义线性布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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