Custom LinearLayout(自定义线性布局)
问题描述
我想做出如下布局:
为此,我需要三个这样的背景:
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.
这篇关于自定义线性布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自定义线性布局
基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
