简体   繁体   中英

ActionBar not showing on android < 5.0

I switched from ABS to AppCompat and Material theme(for api 21 only)

<!--manifest: -->
<application
        android:theme="@style/AppStyle"

<-- values folder -->
<style name="AppStyle" parent="@style/AudioRecTheme">
<style name="AudioRecTheme" parent="@style/Theme.AppCompat.Light">

<!-- values-v21 folder-->
<style name="AudioRecTheme" parent="@android:style/Theme.Material.Light">

My activity:

public class AudioRecActivity extends FragmentActivity

The action bar is showing only in Android 5.0, but missing otherwise.

First, either use appcompat-v7 or use built-in themes, not both for the same activity. Here, you are trying to use Theme.AppCompat.Light in some cases and Theme.Material.Light in others, which is not only unnecessary but AFAIK will not work. If you are going to use Theme.AppCompat.Light , do so for all API levels.

Second, if you are going to use appcompat-v7 and Theme.AppCompat.Light , you need to inherit from ActionBarActivity .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM