[英]Create custom complex xml shape android
要創建自定義形狀,這里是 Github 項目-ShapeOfView
從 ShapeOfView 你可以使用com.github.florent37.shapeofview.shapes.DiagonalView
依賴: implementation 'com.github.florent37:shapeofview:(lastest version)'
試試下面的代碼:
<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>
我希望這個對你有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.