Android中ProgressBar样式

本文详细介绍了如何在Android应用中使用帧动画制作图片序列,并通过自定义样式实现统一的界面风格。重点包括使用clip节点确保不同屏幕上的显示一致性,以及修改系统默认ProgressBar样式的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

两个图片,制作帧动画

需要注意的是,需要使用clip节点来指定android:clipOrientation和android:gravity="left",否则可能出现不同屏幕显示不完整的情况

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:variablePadding = "true">
    <item android:duration="100">
        <clip xmlns:android="http://schemas.android.com/apk/res/android"
            android:clipOrientation="horizontal"
            android:drawable="@drawable/loading_pic1"
            android:gravity="left">
        </clip>
    </item>
    <item android:duration="100">
        <clip xmlns:android="http://schemas.android.com/apk/res/android"
            android:clipOrientation="horizontal"
            android:drawable="@drawable/loading_pic2"
            android:gravity="left">
        </clip>
    </item>
    <item android:duration="100">
        <clip xmlns:android="http://schemas.android.com/apk/res/android"
            android:clipOrientation="horizontal"
            android:drawable="@drawable/loading_pic3"
            android:gravity="left">
        </clip>
    </item>
    <item android:duration="100">
        <clip xmlns:android="http://schemas.android.com/apk/res/android"
            android:clipOrientation="horizontal"
            android:drawable="@drawable/loading_pic4"
            android:gravity="left">
        </clip>
    </item>
</animation-list>





这里写图片描述


Android 系统已经被各大厂商改的面目全非,各种系统组件在不同手机上显示的效果完全不同,现在要想在开发中想要保持统一的界面风格,必须全部修改系统组件的 样式 ,现在我们需要修改系统默认的 ProgressBar ,就 Android 系统本身来说,不同的版本组件的 样式 也不同。vcD4NCjxoMiBpZD0="系统中progressbar样式">系统中 ProgressBar 样式

系统样式


找到android-sdk目录下的platforms\android-15\data\res\values中的styles.xml,然后查找ProgressBar,可以发现

android:indeterminateDrawable的值为@android:drawable/progress_medium_white,找到drawable目录下的progress_medium_white.xml,打开

就是一个简单的spinner_white_48.png的旋转动画

自定义android:indeterminateDrawable的值 旋转动画

然后

即可制作简单的旋转样式的的ProgressBar

帧动画

还有一种样式的为帧动画,这里有一点需要注意的

这里写图片描述

这里写图片描述


两个图片,制作帧动画

需要注意的是,需要使用clip节点来指定android:clipOrientation和android:gravity="left",否则可能出现不同屏幕显示不完整的情况

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值