view画圆实现圆点

来源:互联网 发布:l42f3200e网络设置 编辑:程序博客网 时间:2024/05/22 19:27

xml中的写法

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:gravity="center_horizontal"
    android:orientation="horizontal" >
    <View
        android:id="@+id/vi1"
        android:layout_width="29dp"
        android:layout_height="10dp"
        android:background="@drawable/xuanzhong" />
    <View android:id="@+id/vi2"
        android:layout_width="29dp"
        android:layout_marginLeft="5dp"
        android:background="@drawable/weixuanzhong"
        android:layout_marginRight="5dp"
        android:layout_height="10dp"
        />
    <View android:id="@+id/vi3"
        android:background="@drawable/weixuanzhong"
        android:layout_width="29dp"
        android:layout_height="10dp"
        />
</LinearLayout>
</RelativeLayout>

drawable文件夹中定义两个shape文件

未选中

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#f00"/>
    <corners android:radius="5dp"/>
</shape>

选中

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#00f"/>
    <corners android:radius="5dp"/>
</shape>

0 0
原创粉丝点击