Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Translucent Android ActionBar
    primarykey
    data
    text
    <p>I've been scouring the interwebs (e.g. Android documentation, answers here, etc.) for the answer to what I thought would be a fairly trivial question. How do you achieve a translucent action bar like the ones in <a href="http://coreylatislaw.com/wp-content/uploads/2011/07/google-music.png" rel="nofollow noreferrer">Google Music</a> and <a href="http://coreylatislaw.com/wp-content/uploads/2011/07/youtube.png" rel="nofollow noreferrer">YouTube</a> (links are image examples)?</p> <p>I want video content to be full screen and not constrained/pushed down by the action bar while still leveraging the benefits of a built in UI component. I can obviously use a completely custom view, but I'd rather leverage the ActionBar if possible.</p> <p><strong>Manifest</strong></p> <pre><code>&lt;activity android:name="videoplayer" android:theme="@android:style/Theme.Holo" android:launchMode="singleTop" android:configChanges="keyboardHidden|orientation"/&gt; </code></pre> <p><strong>Activity</strong></p> <pre><code>// Setup action bar ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); View customActionBarView = getLayoutInflater().inflate(R.layout.player_custom_action_bar, null); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, R.dimen.action_bar_height)); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); </code></pre> <p><strong>Menu</strong></p> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@+id/button1" android:icon="@drawable/button1" android:showAsAction="always"/&gt; &lt;item android:id="@+id/button2" android:icon="@drawable/button2" android:showAsAction="always"/&gt; &lt;/menu&gt; </code></pre> <p><strong>Custom ActionBar View</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/custom_action_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:background="@color/TranslucentBlack"&gt; &lt;!--Home icon with arrow--&gt; &lt;ImageView android:id="@+id/home" android:src="@drawable/home" android:layout_width="wrap_content" android:layout_height="match_parent"/&gt; &lt;!--Another image--&gt; &lt;ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="match_parent" android:visibility="visible"/&gt; &lt;!--Text if no image--&gt; &lt;TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:visibility="gone"/&gt; &lt;!--Title--&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingLeft="20dp" android:gravity="center_vertical"/&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload