0

Sorry for the question being too abstract but I really need fresh ideas.

I'm looking for a way to have multimedia keys, volume up and down and several other controls placed into an action bar in Android. Similar to the system action bar (with back and home button) I want the custom one to be visible all the time and on top of every other application's activity. The device to be used is rooted so this might make things easier. I specialize mostly in iOS development that's why I need your help.

Please if somebody has any idea please share it. I just need a direction to start.

EDIT: Sorry it seems like I haven't been understood correctly. What I meant is I want an action bar on top of every application. (Imagine the Facebook messanger's bubbles).

EDIT 2: Solution has been found: Creating a system overlay window (always on top)

Community
  • 1
  • 1

2 Answers2

1

First of all you should use ToolBar. Create an xml file

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        style="@style/CustomActionBar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <ImageButton
            android:id="@+id/vol_plus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_vol_plus_24dp"
            />
        <ImageButton
            android:id="@+id/vol_minus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_vol_minus_24dp"
            />
        <ImageButton
            android:id="@+id/vol_mute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_vol_mute_24dp"
            />

    </android.support.v7.widget.Toolbar>

</android.support.design.widget.AppBarLayout>

Like this you can add controls in Toolbar and can attach in you activity You can also layout for better view

  • Let me just make sure we are on the same page. According to what you have edited in my question I assume you understood me wrong and this is probably my bad. What I need is to place action bad on top of every application. As I understand your suggestion is only applicable within the scope of the current application. – George Penchev Dec 02 '15 at 12:06
  • @GeorgePenchev Fine. You can include it in each activity as you want. –  Dec 02 '15 at 12:19
  • Does this mean that I will have my custom bar on the screen all the time, no matter if the current app is in foreground or not? Cause I seriously doubt it. – George Penchev Dec 02 '15 at 12:43
0

yes you can have the action bar on top of the activity always just you ve to define the toolbar in the activity tht you arte goin to use.

// tool bar xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:local="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar_action"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/ColorPrimaryDark"
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
//inisde the xml
 <include
        android:id="@+id/toolbar_action"
        layout="@layout/toolbar" >
    </include>

//activity class
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
Manoj kumar
  • 440
  • 4
  • 13