一手遮天 Android - UI: shape 形状(矩形,圆形,环形,直线)

项目地址 https://github.com/webabcd/AndroidDemo
作者 webabcd

一手遮天 Android - UI: shape 形状(矩形,圆形,环形,直线)

示例如下:

/ui/ShapeDemo3.java

/**
 * shape 形状(矩形,圆形,环形,直线)
 */

package com.webabcd.androiddemo.ui;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

import com.webabcd.androiddemo.R;

public class ShapeDemo3 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ui_shapedemo3);
    }
}

/layout/activity_ui_shapedemo3.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!--矩形 shape,参见 res/drawable/shape_sample_rectangle.xml-->
    <TextView
        android:id="@+id/textView1"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:background="@drawable/shape_sample_rectangle" />

    <!--圆形 shape,参见 res/drawable/shape_sample_oval.xml-->
    <TextView
        android:id="@+id/textView2"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/shape_sample_oval" />

    <!--环形 shape,参见 res/drawable/shape_sample_ring.xml-->
    <TextView
        android:id="@+id/textView3"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/shape_sample_ring" />

    <!--直线 shape,参见 res/drawable/shape_sample_line.xml-->
    <TextView
        android:id="@+id/textView4"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/shape_sample_line" />

</LinearLayout>

项目地址 https://github.com/webabcd/AndroidDemo
作者 webabcd

posted @ 2021-06-02 08:49  webabcd  阅读(214)  评论(0编辑  收藏  举报