Android,删除圆形进度条周围的方形边框

时间:2016-08-01 20:33:56

标签: java android xml

我有一个通过xml设计的循环进度条。问题是,如果我将layout_width和layout_height设置为wrap_content,它将切断圆圈。如果我手动将宽度和高度设置为“__dp”,那么圆圈周围会有一个巨大的盒子,它会扩展太多。为了更清楚地解释,我的进度条会在您触摸时开始。但是,在它周围有这个边框,即使你触摸进度条旁边它也会启动(当它不应该)。我该如何删除此边框?谢谢!

enter image description here

    <ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:id="@+id/progressBar"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:indeterminate="false"
    android:progressDrawable="@drawable/circular_progress_bar"
    android:background="@drawable/circle_shape"
    android:max="100"
    android:layout_alignParentBottom="true"
    android:layout_centerInParent="true"
    />

circle_shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="7"
    android:thickness="5dp"
    android:useLevel="false">

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

</shape>

circular_progress_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="270"
    android:toDegrees="270">
    <shape
        android:innerRadiusRatio="7"
        android:shape="ring"
        android:thickness="5dp"
        android:useLevel="true">

        <gradient
            android:angle="0"
            android:endColor="#007DD6"
            android:startColor="#007DD6"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

1 个答案:

答案 0 :(得分:1)

你设置了错误的风格。

   style="?android:attr/progressBarStyleHorizontal"

适用于水平ProgressBar s。删除样式或使用一个用于圆形ProgressBar的样式

style="@style/Base.Widget.AppCompat.ProgressBar"
相关问题