How can I remove line or divider between action bar and main screen? How can I change the color of this divider in android? Thanks in advance.
问题:
回答1:
Simply insert the attribute windowContentOverlay to your theme. It's way too simple this way.
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="android:windowContentOverlay">@null</item>
</style>
回答2:
After more effort I can find my ideal Theme.
- First of all i must say that Theme.Holo.Light has a shadow in bottom of action bar if you want to have not that shadow you must use Theme.Holo.
After you change the style you must change other settings for yourself like the code.
<resources> <style name="AppTheme" parent="android:Theme.Holo"> <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item> <item name="android:background">#ff0000</item> <item name="android:colorBackground">#ff0000</item> </style> <style name="AppTheme.ActionBar" parent="android:Widget.ActionBar"> <item name="android:background">#ff0000</item> </style> </resources>
This below code is for my last challange that I found how to resolve it.
<resources> <style name="AppTheme" parent="android:Theme.Holo.Light"> <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item> <item name="android:background">#ff0000</item> <item name="android:colorBackground">#ff0000</item> </style> <style name="AppTheme.ActionBar" parent="android:Widget.ActionBar"> <item name="android:background">#ff0000</item> </style> </resources>
Below Image is for first Code, If you notice there isn't any divider.
- And below Image is for second Code.
回答3:
If you use AppCompat you need set parent="Theme.AppCompat", not "Theme.AppCompat.Light" (the same stands for ActionBar) :)
For example: @style/MyActionBar true @style/MyActionBar true
<style name="MyActionBar" parent="Base.Widget.AppCompat.ActionBar">
<item name="android:background">@android:color/transparent</item>
<!--For compatibility-->
<item name="background">@android:color/transparent</item>
</style>
回答4:
In your styles.xml file , look for your AppTheme style and add the following style into it
<item name="android:actionBarDivider">@android:color/transparent</item>
like this
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">@font/roboto</item>
<item name="android:actionBarDivider">@android:color/transparent</item>
</style>
what it actually does is that it sets the background of the divider between activity window and action bar as transparent.