× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Listview and Action bar TRANSPARENT in android

Xaver Kapeller
Mar 13, 2015
<p>The problem is this:</p> <pre><code>getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); </code></pre> <p>You are telling the <code>ActionBar</code> to be in overlay mode, that means it will overlay the content instead of being at a fixed position above it. This is useful if you want to dynamically hide and show the <code>ActionBar</code> in your app, but it is not required to make the <code>ActionBar</code> transparent. Just remove it and it should work as you expect.</p> <p>If you however want or need the <code>ActionBar</code> in overlay mode than you can just apply a padding to the content in your <code>Activity</code> which is equal to the <code>ActionBar</code> height. Like this:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?android:attr/actionBarSize"&gt; ... &lt;/RelativeLayout&gt; </code></pre> <p>If you are using the support library you have to use <code>?attr/actionBarSize</code> insted of <code>?android:attr/actionBarSize</code> like this:</p> <pre><code>&lt;!-- Support library compatibility --&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?attr/actionBarSize"&gt; ... &lt;/RelativeLayout&gt; </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/25078212/Listview%20and%20Action%20bar%20TRANSPARENT%20in%20android/25078329">Stack Overflow</a>.</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus