Custom view that splits layout diagonally with different child views(自定义视图,用不同的子视图对角分割布局)
问题描述
我怎样才能将 LinearLayout
或 RelativeLayout
对角分割成两个不同的大小,每个都有不同的子视图.上半部分的示例 ViewPager
和下半部分的不同 LinearLayout
.
类似这样的:
我怎样才能做到这一点?请帮忙
最简单的方法是制作带有倾斜剪切的背景图像.如果您希望拥有动态布局并且想要真正剪切小部件,请使用 Canvas.saveLayer/restore.像这样:
要点:
顺便说一句.这东西最近很流行:)
How can i split LinearLayout
or RelativeLayout
diagonally into two varying sizes and each having different child view. Example ViewPager
in upper half section and a different LinearLayout
in bottom section.
something like this :
How can i achieve this? Please help
The easiest approach is to just make a background image with that skewed cut. If you wish to have a dynamic layout and you want to really cut widgets, use Canvas.saveLayer/restore. Like this:
Gist: https://gist.github.com/ZieIony/8480b2d335c1aeb51167
Btw. This thing is very popular recently :)
这篇关于自定义视图,用不同的子视图对角分割布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!