Use toolbar in MainActivity instead of actionbar

This commit is contained in:
daniel oeh 2014-12-04 22:17:21 +01:00
parent 6bba71469f
commit 594dd8cab9
2 changed files with 20 additions and 11 deletions

View File

@ -14,6 +14,7 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -66,6 +67,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
POS_HISTORY = 3, POS_HISTORY = 3,
POS_ADD = 4; POS_ADD = 4;
private Toolbar toolbar;
private ExternalPlayerFragment externalPlayerFragment; private ExternalPlayerFragment externalPlayerFragment;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
@ -81,15 +83,15 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme()); setTheme(UserPreferences.getNoTitleTheme());
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StorageUtils.checkStorageAvailability(this); StorageUtils.checkStorageAvailability(this);
setContentView(R.layout.main); setContentView(R.layout.main);
setVolumeControlStream(AudioManager.STREAM_MUSIC); setVolumeControlStream(AudioManager.STREAM_MUSIC);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
drawerTitle = currentTitle = getTitle(); drawerTitle = currentTitle = getTitle();
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navList = (ListView) findViewById(R.id.nav_list); navList = (ListView) findViewById(R.id.nav_list);
navDrawer = findViewById(R.id.nav_layout); navDrawer = findViewById(R.id.nav_layout);

View File

@ -1,31 +1,38 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content" android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<FrameLayout <FrameLayout
android:id="@+id/playerFragment" android:id="@+id/playerFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/> android:layout_alignParentBottom="true" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"/>
<FrameLayout <FrameLayout
android:id="@+id/main_view" android:id="@+id/main_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_alignParentTop="true" android:layout_above="@id/playerFragment"
android:layout_above="@id/playerFragment"/> android:layout_below="@id/toolbar"
android:foreground="?android:windowContentOverlay" />
</RelativeLayout> </RelativeLayout>
<include layout="@layout/nav_list"/> <include layout="@layout/nav_list" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>