2015-11-08 49 views
1

我正在使用AppCompat和設計庫爲Android 4.0+開發應用程序。在Android 5.0上一切都很好。但在Android 4.0上,我看到了舊的進度條風格。如何在Android 4.0中使用Android 5+的ProgressBar

的Android 5.0
enter image description here

的Android 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 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> 
+0

你可能沒有設置你的'Theme'權,對於版本低於5.0 – Emmanuel

+0

是那個進度條還是找吧? – Androider

+0

這是一個seekbar。但在這種情況下,沒關係 –

回答

2

v7 appcompat庫的版本23.1.0添加了材料設計Seekbar,如您在changelog中所見。

您可能正在使用舊版本的v7 appcompat庫。更新到最新版本和SeekBar將自動以其他小部件的材料設計風格爲主題。

更改應用build.gradle的依賴條件:

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

    ... 
} 

這些都是在Android 4.4中獲得的結果。

,與V7程序兼容性庫v23.0.1:
enter image description here

,與V7程序兼容性庫v23.1.0:
enter image description here

0

我想這AppCompat僅僅是Holo。但5.0 Materialenter image description here

您可以像EditText一樣獲得Widget,但無法獲取進度。

+0

我不明白你的答案。 Android 4.0手機上的所有內容都看起來像Android 5.0手機,不包括此搜索欄。 –