首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用android-drawable绘制流程栏

使用android-drawable绘制流程栏
EN

Stack Overflow用户
提问于 2015-10-24 18:27:20
回答 1查看 68关注 0票数 0

我有一个新用户的3注册页面,我们想添加3个州的每一个进程栏,我们考虑使用android-drawable绘制shipes,任何想法如何实现它。

EN

回答 1

Stack Overflow用户

发布于 2015-10-24 18:38:17

定义圆:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

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

   <size 
       android:width="120dp"
        android:height="120dp"/>
</shape>

然后创建一个水平的ProgressBar,并在上面放3个可绘制的部分。

代码语言:javascript
复制
<RelativeLayout
    android:id="@+id/progress"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ProgressBar
        android:id="@+id/progress_bar"
        style="@style/CustomProgressBarHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/q1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/light_pink_circle"
            android:gravity="center"
            android:text="1"
            android:textColor="#e6e6e6"
            android:textSize="23sp"
            android:textStyle="bold" />

        <View
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_weight="1" >
        </View>

        <TextView
            android:id="@+id/q2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/light_pink_circle"
            android:gravity="center"
            android:text="2"
            android:textColor="#e6e6e6"
            android:textSize="23sp"
            android:textStyle="bold" />

        <View
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_weight="1" >
        </View>

        <TextView
            android:id="@+id/q3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/light_pink_circle"
            android:gravity="center"
            android:text="3"
            android:textColor="#e6e6e6"
            android:textSize="23sp"
            android:textStyle="bold" />
    </LinearLayout>
</RelativeLayout>

创建您的ProgressBar样式:

代码语言:javascript
复制
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
    <shape >
        <gradient
            android:startColor="#39bf96"
            android:centerColor="#39bf96"
            android:centerY="1.0"
            android:endColor="#39bf96"
            android:angle="270"
            />
    </shape>
</item>

<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
    <clip android:gravity="left">
        <shape>
            <gradient
                android:startColor="#31a380"
                android:centerColor="#31a380"
                android:centerY="1.0"
                android:endColor="#31a380"
                android:angle="270"
                />
        </shape>
    </clip>
</item>

在第一个页面上,将progress设置为0,在第二个页面上将其设置为50,在第三个页面上将其设置为100。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33317129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档