[英]Create custom complex xml shape android
How do I create shapes like in an attachment, and use them as backgroungs for TextViews?如何像在附件中一样创建形状,并将它们用作 TextViews 的背景? Also please get me a link to the guides on creating custom complex shapes
另外请给我一个链接到创建自定义复杂形状的指南
To Create custom shape, Here is Github project- ShapeOfView要创建自定义形状,这里是 Github 项目-ShapeOfView
From ShapeOfView you can use com.github.florent37.shapeofview.shapes.DiagonalView
从 ShapeOfView 你可以使用
com.github.florent37.shapeofview.shapes.DiagonalView
Dependancy: implementation 'com.github.florent37:shapeofview:(lastest version)'
依赖:
implementation 'com.github.florent37:shapeofview:(lastest version)'
Try below code:试试下面的代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.github.florent37.shapeofview.shapes.DiagonalView
android:layout_weight=".5"
android:layout_width="0dp"
android:layout_height="40dp"
app:shape_diagonal_angle="-10"
app:shape_diagonal_position="right">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text1"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:background="@drawable/bg_left_side"/>
</com.github.florent37.shapeofview.shapes.DiagonalView>
<com.github.florent37.shapeofview.shapes.DiagonalView
android:layout_weight=".5"
android:layout_width="0dp"
android:layout_height="40dp"
app:shape_diagonal_angle="-10"
app:shape_diagonal_position="left">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text2"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:background="@drawable/bg_right_side"/>
</com.github.florent37.shapeofview.shapes.DiagonalView>
</LinearLayout>
The output for above code is:上述代码的 output 为:
I hope it works for you.我希望这个对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.