ToggleButton,RatingBar,Switch,实例

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context="com.example.testyk.MainActivity">

    <ToggleButton
        android:layout_width="match_parent"
        android:id="@+id/tb"
        android:textOff="关闭"      //关闭时的文字
        android:textOn="打开"      //关闭时的文字
        android:layout_height="wrap_content" />

    <Switch
        android:layout_width="wrap_content"
        android:id="@+id/switch1"
        android:text="请选择"
        android:textOff="取消"   //关闭时的文字
        android:textOn="确定"    //关闭时的文字
        android:layout_height="wrap_content" />

    <RatingBar
        android:layout_width="wrap_content"
        android:id="@+id/rb"
        android:numStars="5"     //星星的总数量
        android:rating="2"           //当前被选中的星星的数量
        android:stepSize="0.5"     //每次最小可以选择半颗星星
        android:layout_height="wrap_content" />

    <RatingBar
        android:layout_width="wrap_content"
        android:id="@+id/rb1"
        android:numStars="6"
        android:rating="3"
        android:isIndicator="true"    //设置不可选择
        android:stepSize="0.5"
        android:layout_height="wrap_content" />
</LinearLayout>



猜你喜欢

转载自blog.csdn.net/yang__k/article/details/80216204