半圆形进度条的Andr​​oid - 绘制半圆 [英] Semi Circular Progress bar Android - drawing semi circle

查看:1242
本文介绍了半圆形进度条的Andr​​oid - 绘制半圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用此 devadvance \ circularSeekBar 一个半圆形进度条 它看起来像这样当我选择从调色板的自定义视图。

在此我有一个权重相对而言的布局。含进度条布局的重量为2和底部1有重量的3.与布局宽度和进度条的高度设置为包裹内容

所以,我的问题是为什么在进度条是这样的,从调色板中选择的时候?难道画布大小取完全平方?我要的是半圆形进度条完全由这样的布局封闭。

在这个任何光线AP preciated。

修改 XML code

< XML版本=1.0编码=UTF-8? > < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android     的xmlns:工具=htt​​p://schemas.android.com/tool​​s     机器人:ID =@ + ID / main_parent_view     机器人:layout_width =match_parent     机器人:layout_height =match_parent     机器人:方向=垂直     机器人:fitsSystemWindows =真正的>     <包括布局=@布局/工具栏/>     < android.support.v4.widget.DrawerLayout         机器人:ID =@ + ID / drawer_layout         机器人:layout_width =match_parent         机器人:layout_height =0dp         机器人:layout_weight =3>         <的LinearLayout             机器人:ID =@ + ID / content_frame             机器人:layout_width =match_parent             机器人:layout_height =match_parent             机器人:方向=垂直>             < RelativeLayout的的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto                 机器人:ID =@ + ID / calorie_frame                 机器人:layout_width =match_parent                 机器人:layout_height =match_parent                 机器人:layout_weight =2                 机器人:可点击=真正的>                 < com.devadvance.circularseekbar.CircularSeekBar                     机器人:ID =@ + ID / calorie_progressbar                     机器人:layout_width =WRAP_CONTENT                     机器人:layout_height =WRAP_CONTENT                     应用程序:start_angle =180                     应用程序:end_angle =0                     应用程序:进度=25                     应用程序:circle_x_radius =200                     应用程序:circle_y_radius =200                     应用程序:circle_stroke_width =30                     应用程序:use_custom_radii =真                     应用程序:circle_color =#FFFACD                     机器人:layout_alignParentEnd =假                     机器人:layout_alignParentStart =假                     机器人:layout_centerInParent =真/>                 < / RelativeLayout的>             < RelativeLayout的                 机器人:ID =@ + ID / exercise_frame                 机器人:layout_width =match_parent                 机器人:layout_height =match_parent                 机器人:layout_weight =3                 机器人:可点击=真正的>                 <的TextView                     机器人:layout_width =WRAP_CONTENT                     机器人:layout_height =WRAP_CONTENT                     机器人:textAppearance =机器人:ATTR / textAppearanceMedium                     机器人:文本=@字符串/ calorie_label                     机器人:ID =@ + ID / TextView的                     机器人:layout_marginBottom =40dp                     机器人:layout_alignParentBottom =真                     机器人:layout_alignParentRight =真                     机器人:layout_alignParentEnd =真                     机器人:layout_marginRight =20dp/>                 < ImageView的                     机器人:layout_width =WRAP_CONTENT                     机器人:layout_height =WRAP_CONTENT                     机器人:ID =@ + ID / ImageView的                     机器人:layout_alignBottom =@ + ID / TextView的                     机器人:layout_alignParentLeft =真                     机器人:layout_alignParentStart =真                     机器人:layout_marginLeft =50dp                     机器人:layout_marginStart =50dp                     机器人:contentDescription =@字符串/ exercise_image/>             < / RelativeLayout的>         < / LinearLayout中>         <的ListView             机器人:ID =@ + ID / left_drawer             机器人:layout_width =240dp             机器人:layout_height =match_parent             机器人:layout_gravity =开始             机器人:choiceMode =singleChoice             机器人:分隔=@机器人:彩色/透明             机器人:dividerHeight =0dp             机器人:后台=#999/>     < /android.support.v4.widget.DrawerLayout> < / LinearLayout中>

解决方案

我依然没有找到为什么会发生如图所示,但我的猜测是,它应该工作一样的道理。反正我这个代之以 lzyzsd / CircleProgress 和它的作品pretty的不够好,我的用例。

相似真棒的东西都可以在这里找到 Android的阿森纳

I created a semi circular progress bar using this devadvance\circularSeekBar and it looks like this when I select that custom view from the palette.

.

In this I have two Relative layouts with weights. Weight of the layout containing the progress bar is 2 and the bottom one has weight of 3. And layout width and height of the progress bar is set to wrap content.

So my issue is why does the progress bar look like this when selected from palette? Is it that the canvas size takes the perfect square? What I want is the semi circular progress bar to be fully enclosed by the layout like this.

Any light on this is appreciated.

EDIT xml code

<?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:id="@+id/main_parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <include layout="@layout/toolbar"/>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3">

        <LinearLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <RelativeLayout xmlns:app = "http://schemas.android.com/apk/res-auto"
                android:id ="@+id/calorie_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:clickable="true">
                <com.devadvance.circularseekbar.CircularSeekBar
                    android:id="@+id/calorie_progressbar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:start_angle = "180"
                    app:end_angle = "0"
                    app:progress = "25"
                    app:circle_x_radius="200"
                    app:circle_y_radius="200"
                    app:circle_stroke_width = "30"
                    app:use_custom_radii="true"
                    app:circle_color ="#FFFACD"

                    android:layout_alignParentEnd="false"
                    android:layout_alignParentStart="false"
                    android:layout_centerInParent="true" />
                </RelativeLayout>

            <RelativeLayout
                android:id="@+id/exercise_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:clickable="true">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:text="@string/calorie_label"
                    android:id="@+id/textView"
                    android:layout_marginBottom="40dp"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true"
                    android:layout_marginRight="20dp" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView"
                    android:layout_alignBottom="@+id/textView"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_marginLeft="50dp"
                    android:layout_marginStart="50dp"
                    android:contentDescription="@string/exercise_image" />

            </RelativeLayout>
        </LinearLayout>

        <ListView
            android:id="@+id/left_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="#999"/>
    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

解决方案

I still didn't find the reason why it happens as shown but my guess is that it's supposed to work like that. Anyway I replaced it with this lzyzsd/CircleProgress and it works pretty well enough for my use case.

Similar awesome stuff can be found here android-arsenal

这篇关于半圆形进度条的Andr​​oid - 绘制半圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆