自定义线性布局

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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)