簡體   English   中英

創建直角三角形的可繪制形狀

[英]create drawable shape of right angled triangle

我試圖找出如何使用 drawable xml ( <shape> ) 來創建一個直角三角形,如下所示(但填充顏色而沒有黑線):

在此處輸入圖片說明

我試着從對角線對半矩形的角度思考,但仍然......找不到如何實現它。

Android drawable xml 是否可行?

干得好:

創建您的 xml 文件

<?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>

在 drawable 文件夾中創建 my_shape6.xml

<?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>

結果

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM