Android使用xml自定义图片

白色圆角图片

bg_round_rectangle_white.xml


<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    
    <solid android:color="#FFFFFF" />

    
    <corners
        android:radius="2dp"/>

    
    <stroke
        android:width="1dp"
        android:color="#D5D5D5"/>

shape>

白色圆角虚线框

bg_round_rectangle_white_dash.xml


<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    
    <solid android:color="#FFFFFF" />

    
    <corners
        android:radius="2dp"/>

    
    <stroke
        android:width="1dp"
        android:color="#DD4041"
        android:dashWidth="1dp"
        android:dashGap="2dp"/>

shape>

红色圆角图片

bg_round_rectangle_red.xml


<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    
    <solid android:color="#F15C5D" />

    
    <corners
        android:radius="2dp"/>

    
    <stroke
        android:width="1dp"
        android:color="#D42D2E"/>

shape>

绿色圆角图片

bg_round_rectangle_green.xml


<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    
    <solid android:color="#88C14E" />

    
    <corners
        android:radius="2dp"/>

    
    <stroke
        android:width="1dp"
        android:color="#6FA13C"/>

shape>

正三角形图片

triangle_white_arrow_up.xml


<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="45"
    android:toDegrees="45"
    android:pivotX="-40%"
    android:pivotY="80%">

    <shape android:shape="rectangle">
        <solid android:color="#000000"/>
    shape>

rotate>

倒立正三角形图片

triangle_white_arrow_down.xml


<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="45"
    android:toDegrees="45"
    android:pivotX="135%"
    android:pivotY="15%">

    <shape android:shape="rectangle">
        <solid android:color="#000000"/>
    shape>

rotate>

实际效果

Android使用xml自定义图片_第1张图片

你可能感兴趣的:(android,xml,自定义图形,Android,基础)