Android seekBar2.环形进度条

1.在res/values/attrs.xml中自定义属性:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="CircleSeekBar">
        <attr name="android:thumb" />
        <attr name="progress_width" format="dimension" />
        <attr name="progress_background" format="color" />
        <attr name="progress_front" format="color" />
        <attr name="progress_max" format="integer" />
        <attr name="show_progress_text" format="boolean" />
        <attr name="progress_text_stroke_width" format="dimension" />
        <attr name="progress_text_color" format="color" />
        <attr name="progress_text_size" format="dimension" />
    </declare-styleable>
</resources>

2.使用attrs.xml中的属性定义自定义布局文件中的CircleSeekBar的属性:(activity_main.xml文件)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:circle_seekbar="http://schemas.android.com/apk/res/com.example.android_seekbar02"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <com.example.util.CircleSeekBar
        android:id="@+id/circle_seekbar"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerInParent="true"
        android:thumb="@drawable/thumb"        
        circle_seekbar:progress_background="@android:color/darker_gray"
        circle_seekbar:progress_front="@android:color/holo_blue_light"
        circle_seekbar:progress_max="1000"
        circle_seekbar:progress_text_color="@android:color/holo_green_light"
        circle_seekbar:progress_text_size="30dp"
        circle_seekbar:progress_text_stroke_width="4dp"
        circle_seekbar:progress_width="2dp"
        circle_seekbar:show_progress_text="true" 
        />
</RelativeLayout>

第二行的xmlns是使用xml的命名空间(namespace)有了他,你就可以alt+/作为提示,提示你输入什么,不该输入什么,什么是对的,什么是错的,也可以理解为语法文件。其格式如下:xmlns:前缀= http://schemas.android.com/apk/res/
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值