I have an Activity
where I would like to have it's ActionBar
transparent.
I am using API Level 18
and my Activity is an AppCompatActivity
I have tried many solutions on StackOverFlow but they dont seem to work
This is the latest one I tried
<!-- Application theme. -->
<style name="AppTheme.TransparentActionBar" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ACTION BAR STYLES -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="background">@android:color/transparent</item>
<item name="windowActionBarOverlay">true</item>
</style>
It simply turned the ActionBar
to white. All solutions I've came up with turns the ActionBar
to white.
Any thoughts?
I have also tried this code
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setContentView(R.layout.activity_login);
}
My activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorYellow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LoginActivity">
</RelativeLayout>
EDIT
Actually the ActionBar
is transparent. But the contentView itself is not underneath it. How can I possibly place the contentView underneath the ActionBar
?