gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 20:17:57 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com