[Android] Switch to Toolbar as an ActionBar

Geoffrey Métais git at videolan.org
Wed Feb 25 17:00:31 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 23 16:29:27 2015 +0100| [a6f5e5adfa05058b93a41dea5b6aa0d96c180c07] | committer: Geoffrey Métais

Switch to Toolbar as an ActionBar

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a6f5e5adfa05058b93a41dea5b6aa0d96c180c07
---

 vlc-android/res/layout/main.xml                    |  139 +++++++++++---------
 vlc-android/res/values/styles.xml                  |    4 +-
 .../src/org/videolan/vlc/gui/MainActivity.java     |    4 +
 3 files changed, 82 insertions(+), 65 deletions(-)

diff --git a/vlc-android/res/layout/main.xml b/vlc-android/res/layout/main.xml
index 9a7b7ea..5a9871b 100644
--- a/vlc-android/res/layout/main.xml
+++ b/vlc-android/res/layout/main.xml
@@ -1,80 +1,93 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.v4.widget.DrawerLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/root_container"
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:nextFocusLeft="@+id/ml_menu_search"
-    android:nextFocusRight="@+id/ml_menu_search"
-    android:nextFocusUp="@+id/ml_menu_search"
-    android:nextFocusDown="@+id/ml_menu_search"
-    android:nextFocusForward="@+id/ml_menu_search">
+    android:orientation="vertical">
 
-    <org.videolan.vlc.widget.SlidingPaneLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:vlc="http://schemas.android.com/apk/res-auto"
-        android:id="@+id/pane"
+    <android.support.v4.widget.DrawerLayout
+        android:id="@+id/root_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        vlc:overhangSize="60dp" >
+        android:nextFocusLeft="@+id/ml_menu_search"
+        android:nextFocusRight="@+id/ml_menu_search"
+        android:nextFocusUp="@+id/ml_menu_search"
+        android:nextFocusDown="@+id/ml_menu_search"
+        android:nextFocusForward="@+id/ml_menu_search"
+        android:fitsSystemWindows="true">
 
-        <org.videolan.vlc.widget.ContentLinearLayout
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:orientation="vertical" >
+        <org.videolan.vlc.widget.SlidingPaneLayout
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            xmlns:vlc="http://schemas.android.com/apk/res-auto"
+            android:id="@+id/pane"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            vlc:overhangSize="60dp" >
 
-		<View
-	        android:layout_width="fill_parent"
-	        android:layout_height="?attr/actionBarSize"
-	        android:background="@drawable/actionbar_background" />
-
-            <FrameLayout
-                android:id="@+id/fragment_placeholder"
+            <org.videolan.vlc.widget.ContentLinearLayout
                 android:layout_width="fill_parent"
-                android:layout_height="0dp"
-                android:layout_weight="1" />
+                android:layout_height="fill_parent"
+                android:orientation="vertical" >
 
-            <RelativeLayout
-                android:id="@+id/info_layout"
-                android:layout_width="fill_parent"
-                android:layout_height="20dp"
-                android:visibility="gone" >
+                <View
+                    android:layout_width="fill_parent"
+                    android:layout_height="?attr/actionBarSize"
+                    android:background="@drawable/actionbar_background" />
+
+                <FrameLayout
+                    android:id="@+id/fragment_placeholder"
+                    android:layout_width="fill_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1" />
 
-                <ProgressBar
-                    android:id="@+id/info_progress"
-                    style="?android:attr/progressBarStyleHorizontal"
+                <RelativeLayout
+                    android:id="@+id/info_layout"
                     android:layout_width="fill_parent"
-                    android:layout_height="fill_parent"
-                    android:progressDrawable="@drawable/progress" />
+                    android:layout_height="20dp"
+                    android:visibility="gone" >
 
-                <TextView
-                    android:id="@+id/info_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="5dip"
-                    android:layout_marginRight="5dip"
-                    android:shadowColor="#CC000000"
-                    android:shadowDx="1"
-                    android:shadowDy="1"
-                    android:shadowRadius="1.5"
-                    android:singleLine="true"
-                    android:textColor="#FFFFFFFF" />
-            </RelativeLayout>
+                    <ProgressBar
+                        android:id="@+id/info_progress"
+                        style="?android:attr/progressBarStyleHorizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="fill_parent"
+                        android:progressDrawable="@drawable/progress" />
 
-            <View
-                android:id="@+id/audio_player_filling"
+                    <TextView
+                        android:id="@+id/info_text"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginLeft="5dip"
+                        android:layout_marginRight="5dip"
+                        android:shadowColor="#CC000000"
+                        android:shadowDx="1"
+                        android:shadowDy="1"
+                        android:shadowRadius="1.5"
+                        android:singleLine="true"
+                        android:textColor="#FFFFFFFF" />
+                </RelativeLayout>
+
+                <View
+                    android:id="@+id/audio_player_filling"
+                    android:layout_width="fill_parent"
+                    android:layout_height="60dp"
+                    android:visibility="gone" />
+            </org.videolan.vlc.widget.ContentLinearLayout>
+
+            <FrameLayout
+                android:id="@+id/audio_player"
                 android:layout_width="fill_parent"
-                android:layout_height="60dp"
-                android:visibility="gone" />
-        </org.videolan.vlc.widget.ContentLinearLayout>
+                android:layout_height="fill_parent" />
+        </org.videolan.vlc.widget.SlidingPaneLayout>
 
-        <FrameLayout
-            android:id="@+id/audio_player"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent" />
-    </org.videolan.vlc.widget.SlidingPaneLayout>
+        <!-- The navigation drawer -->
+        <include layout="@layout/sidebar"/>
+    </android.support.v4.widget.DrawerLayout>
 
-    <!-- The navigation drawer -->
-	<include layout="@layout/sidebar"/>
-    
-</android.support.v4.widget.DrawerLayout>
+    <android.support.v7.widget.Toolbar
+        android:id="@+id/main_toolbar"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:minHeight="?attr/actionBarSize"
+        android:background="@drawable/actionbar_background" />
+</FrameLayout>
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index c6e7b33..3f5576c 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -16,7 +16,7 @@
         <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
     </style>
 
-    <style name="Theme.VLC.Apearance" parent="Theme.AppCompat.Light">
+    <style name="Theme.VLC.Apearance" parent="Theme.AppCompat.Light.NoActionBar">
         <item name="marginTopContent">50dp</item>
 
         <item name="android:listViewStyle">@style/Theme.VLC.List</item>
@@ -86,7 +86,7 @@
         <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
     </style>
 
-    <style name="Theme.VLC.Apearance.Black" parent="Theme.AppCompat">
+    <style name="Theme.VLC.Apearance.Black" parent="Theme.AppCompat.NoActionBar">
         <item name="marginTopContent">50dp</item>
 
         <item name="android:listViewStyle">@style/Theme.VLC.List</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 64335f7..1838c88 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -42,6 +42,7 @@ import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBarActivity;
 import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.widget.Toolbar;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -187,6 +188,9 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
 
         setContentView(R.layout.main);
 
+        Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
+        setSupportActionBar(toolbar);
+
         mSlidingPane = (SlidingPaneLayout) findViewById(R.id.pane);
         mSlidingPane.setPanelSlideListener(mPanelSlideListener);
 



More information about the Android mailing list