android中的方形边缘不确定进度条

我正在尝试在xml中自定义一个不确定的进度条,但我找不到方法来对齐边缘.我从SDK资源中找到了认的xml drawable,但它们只引用了PNG而没有提到形状.

这是SDK资源中的认xml:

<?xml version="1.0" encoding="utf-8"?>
<animation-list
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:oneshot="false">
    <item android:drawable="@drawable/progressbar_indeterminate1" android:duration="200" />
    <item android:drawable="@drawable/progressbar_indeterminate2" android:duration="200" />
    <item android:drawable="@drawable/progressbar_indeterminate3" android:duration="200" />
</animation-list>

progressbar_indeterminate1,2和3只是方形PNG,但它始终显示带有圆边的进度条.

我尝试过创建一个形状并使用PNG作为背景:

<animation-list
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:oneshot="false">

   <item
        android:drawable="@drawable/progressbar_indeterminate1"
        android:duration="200">
        <shape>
            <corners android:radius="0dp" />
        </shape>
    </item>

</animation-list>

但它并没有改变形状.我发布了图片,但我还没有足够的声誉.
我错过了什么?谢谢你的帮助.

解决方法

我只是有同样的问题,似乎使用XML设置的不确定drawable有圆角.如果您需要方形(或可能是任何其他)边缘,则需要使用以下代码设置不确定的drawable:
// line below is needed to have sharp corners in the indeterminate drawable,// ProgressBar when parsing indeterminate drawable from XML sets rounded corners.
progressBar.setIndeterminateDrawable(context.getResources().getDrawable(R.drawable.progressbar_indeterminate));

然后是我使用的progressbar_indeterminate示例:

<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
 <item android:drawable="@drawable/progress_2b" android:duration="100" />
 <item android:drawable="@drawable/progress_1b" android:duration="100" />
</animation-list>

我需要重复图像,所以我创建了progress_1b(和2b),如下所示:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/progress_1"
    android:tileMode="repeat" >
</bitmap>`

drawable / progress_1是真实图像,我想重复作为不确定进度条的背景.

这个解决方案对我有用.

相关文章

Android 通过adb shell命令查看内存,CPU,启动时间,电量等...
Monkey Android app稳定性测试工具之Monkey使用教程 by:授客...
Android 常见adb命令 by:授客 QQ:1033553122 1、 查看所有已...
这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...