我试图找出如何使用drawable xml(<shape>
)来创建一个像下面这样的直角三角形(但填充没有黑线的颜色):
我试着从对角线上减半矩形的角度思考,但仍然......无法找到如何实现它。
Android drawable xml是否可行?
答案 0 :(得分:2)
你走了:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.ul_ts.emvsdktester.drawabletraining.Main10Activity">
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/my_shape6"></LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportHeight="100"
android:viewportWidth="100">
<path
android:fillColor="#32c2b6"
android:pathData="M0 20 L100 0 L100 20 Z"
android:strokeColor="#9a1616" />
</vector>