android - 如何在 Android 4.0 中使用 Android 5+ 的 ProgressBar

标签 android user-interface layout android-appcompat

我正在使用 AppCompat 和设计库开发适用于 Android 4.0+ 的应用程序。在 Android 5.0 上一切看起来都很好。但是在 Android 4.0 上,我看到了旧的进度条样式。

安卓5.0
enter image description here

安卓4.0
enter image description here

XML 布局:

<FrameLayout 
    android:background="@color/colorPrimary"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <SeekBar
        android:id="@+id/play_seek_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</FrameLayout>

样式:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>

    <style name="ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <item name="colorControlActivated">#fff</item>
    </style>
</resources>

Activity 声明:

<activity android:name=".ui.PlayListsActivity"
    android:launchMode= "singleInstance"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:label="@string/app_name">

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>

</activity>

最佳答案

v7 appcompat 库的版本 23.1.0 添加了 Material 设计 Seekbar,如您在 changelog 中所见.

您可能正在使用旧版本的 v7 appcompat 库。更新到最新版本后,SeekBar 将像其他小部件一样自动采用 Material Design 样式作为主题。

改变你的应用build.gradle的依赖:

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'

    ...
}

这些是在 Android 4.4 上获得的结果。

使用 v7 appcompat 库 v23.0.1:
enter image description here

使用 v7 appcompat 库 v23.1.0:
enter image description here

关于android - 如何在 Android 4.0 中使用 Android 5+ 的 ProgressBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33594973/

相关文章:

android - 如何检查 Activity 是从通知启动的还是从用户单击android中的主屏幕仪表板应用程序图标启动的

Android 构建不起作用(在模块中发现重复的类 com.google.android.gms.internal.measurement.zzbt)

C#:如何将完整的 ContextMenu 添加到 MenuItem 作为子菜单

c++ - 使用工厂模式来实例化所有小部件是否明智?

php - 如何更改 Opencart 中的主题布局?

android - 几秒钟后如何删除 ListView 项目?

Android - 3 列行布局 - 如何让它占据屏幕的百分比?

c++ - 向 C++ 软件添加 GUI 的最佳语言

html - 2 列布局,内容宽度固定,背景宽度不限

layout - 如何使表示二叉树的点图更对称?