virtual<一>
1,创建如下新文件
froyo\frameworks\base\core\res\res\layout\control_panel.xml 代码如下
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
This is the basic layout for a screen, with all of its features enabled.
-->
<!-- Title bar and content -->
<com.android.server.status.SystemMenuBarView xmlns:android="http://schemas.android.com/apk/res/android"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
>
<!-- Title bar -->
<ImageView android:id="@+id/panel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/panel_back"
android:padding="2dip"
/>
<ImageView android:id="@+id/panel2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/panel_search"
android:padding="2dip"
/>
<ImageView android:id="@+id/panel3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/panel_menu"
android:padding="2dip"
/>
<ImageView android:id="@+id/panel4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/panel_home"
android:padding="2dip"
/>
</com.android.server.status.SystemMenuBarView>
另外 添加布局文件对应的图片资源文件,分竖屏和横屏
froyo\frameworks\base\services\java\com\android\server\status\SystemMenuBarView.java 代码如下
package com.android.server.status;
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.android.internal.R;
public class SystemMenuBarView extends LinearLayout {
private Context mContext;
private int mOrientation = -1;
private int mCount = 0;
private ImageView iv1, iv2, iv3, iv4;
public SystemMenuBarView(Context context) {
super(context);
// TODO Auto-generated constructor stub
this.mContext = context;
}
public SystemMenuBarView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
iv1 = (ImageView)findViewById(R.id.panel1);
iv2 = (ImageView)findViewById(R.id.panel2);
iv3 = (ImageView)findViewById(R.id.panel3);
iv4 = (ImageView)findViewById(R.id.panel4);
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
if (mOrientation != newConfig.orientation){
//Log.i("orie", "mCount:" + mCount++ + " mOrientation: " + mOrientation + " newConfig.orientation: " + newConfig.orientation);
mOrientation = newConfig.orientation;
if (newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
Log.i("orie", "land");
setOrientation(LinearLayout.VERTICAL);
iv1.setImageResource(R.drawable.panel_back);
iv2.setImageResource(R.drawable.panel_search);
iv3.setImageResource(R.drawable.panel_menu);
iv4.setImageResource(R.drawable.panel_home);
}else{
Log.i("orie", "port");
setOrientation(LinearLayout.HORIZONTAL);
iv1.setImageResource(R.drawable.panel_home);
iv2.setImageResource(R.drawable.panel_menu);
iv3.setImageResource(R.drawable.panel_search);
iv4.setImageResource(R.drawable.panel_back);
}
}
Log.i("orie", "executed");
super.onConfigurationChanged(newConfig);
}
}