android - 创建自定义复杂的xml形状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>
我希望这个对你有用。
推荐阅读
- c++ - 当我使用 get_current_dir_name() 时 JsonCpp 找不到文件
- sql-server - 将数据从服务器表迁移到另一个服务器表
- ibm-doors - 如何使用 DXL 从文件或流中获取修改日期?
- python - 整理来自多个 pytest 运行的结果
- ruby-on-rails - Heroku + rails + svelte 部署
- javascript - 如何使此面包屑模式生成器正常工作
- symfony - google-api-php-client 语音转文本:未设置 RecognitionAudio
- angular - NgModel 并不总是更新文本输入
- reactjs - 我在我的应用程序中使用带有 useContext 和 useReducer 的 typescript 使用 React,但由于某种原因,单击不会触发调度
- php - 如何注册 yii@1.1 的扩展?