android4.0上状态栏上加入虚拟按键

1.在状态栏的xml下加入类似的布局 具体实现在com.android.systemui.statusbar.policy.KeyButtonView
2.加入图片
3.在竖屏的时候默认隐藏,横屏的时候出现
--- a/ frameworks/base/packages/SystemUI/res/layout-sw600dp/status_bar.xml
+++ b/ frameworks/base/packages/SystemUI/res/layout-sw600dp/status_bar.xml
@@ -76,6 +76,39 @@
                     android:contentDescription="@string/accessibility_recent"
                     systemui:glowBackground="@drawable/ic_sysbar_highlight"
                     />
+                        <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/volume_down"
+                android:layout_width="80dp"
+                android:layout_height="match_parent"
+                android:src="@drawable/sub_normal"
+                systemui:keyCode="25"
+                systemui:keyRepeat="false"
+                android:layout_weight="0"
+                systemui:glowBackground="@drawable/ic_sysbar_highlight"
+                android:contentDescription="@string/accessibility_home"
+                />
+       <!--     <View 
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:visibility="invisible"
+                />-->
+            <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/volume_up"
+                android:layout_width="80dp"
+                android:layout_height="match_parent"
+                android:src="@drawable/add_normal"
+                systemui:keyCode="24"
+                systemui:keyRepeat="false"
+                android:layout_weight="0"
+                systemui:glowBackground="@drawable/ic_sysbar_highlight"
+                android:contentDescription="@string/accessibility_home"
+                />
+ <!--           <View 
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:visibility="invisible"
+                />
+-->
                 <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
                     android:layout_width="80dip"
                     android:layout_height="match_parent"
hide the volume_key in statusBar when in portrait screen   R91P1_all_custom
author Lifeng Wang <[email protected]>  
  Fri, 6 Jul 2012 02:01:52 +0000 (10:01 +0800)
committer Lifeng Wang <[email protected]>  
  Fri, 6 Jul 2012 02:01:52 +0000 (10:01 +0800)
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java  

diff --git   a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index   4454882.. a1626c5  100644  (file)
--- a/ frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/ frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -136,6 +136,8 @@  public class TabletStatusBar extends StatusBar implements
     NotificationIconArea mNotificationIconArea;
     ViewGroup mNavigationArea;
 
+    ImageView mbut_add;
+    ImageView mbut_sub;
     boolean mNotificationDNDMode;
     NotificationData.Entry mNotificationDNDDummyEntry;
 
@@ -418,6 +420,18 @@  public class TabletStatusBar extends StatusBar implements
         WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel,
                 mNotificationPanelParams);
         mRecentsPanel.updateValuesFromResources();
+        if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE)
+              {
+                   Log.i("orien", "Configuration.ORIENTATION_LANDSCAPE");
+                   mbut_add.setVisibility(View.VISIBLE);
+                   mbut_sub.setVisibility(View.VISIBLE);
+              }
+              else if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT)
+              {
+                   Log.i("orien", "Configuration.ORIENTATION_PORTRAIT");
+                   mbut_add.setVisibility(View.GONE);
+                   mbut_sub.setVisibility(View.GONE);
+              }
     }
 
     protected void loadDimens() {
@@ -537,6 +551,8 @@  public class TabletStatusBar extends StatusBar implements
         mRecentButton = mNavigationArea.findViewById(R.id.recent_apps);
         mRecentButton.setOnClickListener(mOnClickListener);
         mNavigationArea.setLayoutTransition(mBarContentsLayoutTransition);
+        mbut_add=(ImageView)mNavigationArea.findViewById(R.id.volume_up);
+        mbut_sub=(ImageView)mNavigationArea.findViewById(R.id.volume_down);
         // no multi-touch on the nav buttons
         mNavigationArea.setMotionEventSplittingEnabled(false);
 

你可能感兴趣的:(c,xml,android,File,layout,UP)