仿优酷菜单效果

来源:互联网 发布:易语言lua源码 编辑:程序博客网 时间:2024/06/03 18:28
优酷中的效果:
仿优酷菜单效果 - 无尘 - 冷冽无尘
 
仿优酷菜单效果 - 无尘 - 冷冽无尘

前言:
    因为子菜单个数不定,所以不能通过xml布局设置边距来实现。
原理:
    不管个数是多少,都会围成一个圆。所以我是通过自定义view(继承自view)然后在半径一定的圆内绘制并监听各个子菜单。
源码:
MenuView.java(自定义菜单view):

package hhf.youku.menu;

import hhf.youku.tools.AppUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
* 菜单view
* @author huanghaifeng
*
*/
public class MenuView extends View{
private Context mContext;
private Paint mPaint;
private float angle;
private float radius = 120f;
private float screenWidth,screenHeight;
public Bitmap subMenuBitmaps[];
private List<double[]> range = new ArrayList<double[]>();;
private List<Map<String,Object>> sourceList = new ArrayList<Map<String,Object>>();

private OnKeyDownListener okl;
private boolean isListened = false;

public MenuView(Context context) {
super(context);
mContext = context;
init();
}

public MenuView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
mContext = context;
init();
}



private void init(){
mPaint = new Paint();
mPaint.setColor(Color.RED);
mPaint.setAntiAlias(true);

screenWidth = AppUtils.getScreenRange(mContext)[0];
screenHeight = AppUtils.getScreenRange(mContext)[1];
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);

canvas.drawCircle(screenWidth/2, screenHeight/2, radius, mPaint);

range.clear();//因为每次ondraw都为range赋值,所以这里先清一次,否则会越界
if(subMenuBitmaps != null && subMenuBitmaps.length > 0){
canvas.drawBitmap(subMenuBitmaps[0], screenWidth/2 - subMenuBitmaps[0].getWidth()/2,
screenHeight/2 - subMenuBitmaps[0].getHeight()/2, mPaint);
double[] temp = new double[2];
temp[0] = screenWidth/2;
temp[1] = screenHeight/2;
range.add(temp);
for(int i = 1 ;i<subMenuBitmaps.length;i++){
temp = new double[2];
float sweepAngle = angle*(i-1) + angle/2;
double x = 0d;
double y = 0d;
double adjacentSide = Math.abs(Math.cos(sweepAngle*Math.PI/180)*(radius/2)*4/3);//邻边 *4/3
double oppositeSide = Math.abs(Math.sin(sweepAngle*Math.PI/180)*(radius/2)*4/3);//对边 *4/3
//顺时针
if(sweepAngle >= 0 && sweepAngle < 90){
// System.out.println("第一象限");
x = adjacentSide + screenWidth/2;
y = oppositeSide + screenHeight/2;
}else if(sweepAngle >= 90 && sweepAngle < 180){
// System.out.println("第二象限");
x = screenWidth/2 - adjacentSide;
y = oppositeSide + screenHeight/2;
}else if(sweepAngle >= 180 && sweepAngle < 270){
// System.out.println("第三象限");
x = screenWidth/2 - adjacentSide;
y = screenHeight/2 - oppositeSide;
}else {
// System.out.println("第四象限");
x = adjacentSide + screenWidth/2;
y = screenHeight/2 - oppositeSide;
}
canvas.drawBitmap(subMenuBitmaps[i], (float)(x - subMenuBitmaps[i].getWidth()/2),
(float)(y - subMenuBitmaps[i].getHeight()/2), mPaint);
temp[0] = x;
temp[1] = y;
range.add(temp);
isListened = false;
}
}
}

@Override
public boolean onTouchEvent(MotionEvent event) {
int pointer = event.getPointerCount();
if(pointer == 1){
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
float x = event.getX();
float y = event.getY();

if(range != null && range.size()>0){
for(int i = 0 ;i<range.size();i++){
if(x >= range.get(i)[0]-subMenuBitmaps[i].getWidth()/2 &&
x <= range.get(i)[0]+subMenuBitmaps[i].getWidth()/2 &&
y >= range.get(i)[1]-subMenuBitmaps[i].getHeight()/2 &&
y <= range.get(i)[1]+subMenuBitmaps[i].getHeight()/2
){
if(okl != null){
if(i != 0){
if((Boolean) sourceList.get(i).get("hasNext")){
okl.onKeyNextListener(i);
isListened = true;
}else{
okl.onKeyDetailListener(i);
isListened = false;
}
}else{
if("-1".equals(sourceList.get(i).get("parentId"))){
okl.onKeyCloseListener(i);
isListened = false;
}else{
okl.onKeyFrontListener(i);
isListened = true;
}
}
}else{
isListened = false;
}
break;
}else{
isListened = false;
}
}

}else{
isListened = false;
}
break;
}
}

// if(isListened){
// return true;
// }else{
// return false;
// }
return isListened;

}

public List<Map<String, Object>> getSourceList() {
return sourceList;
}

public void setSourceList(List<Map<String, Object>> sourceList) {
this.sourceList = sourceList;
if(sourceList.size() > 0){
subMenuBitmaps = null;
subMenuBitmaps = new Bitmap[sourceList.size()];
for(int i = 0 ;i< sourceList.size();i++){
System.out.println("第 " + i +"个bitmap = " + (Bitmap) sourceList.get(i).get("bitmap"));
subMenuBitmaps[i] = (Bitmap) sourceList.get(i).get("bitmap");
}
if(subMenuBitmaps.length > 1){
angle = 360/(subMenuBitmaps.length-1);
}
}
range.clear();
invalidate();
}

public void setOnKeyDownListener(OnKeyDownListener okl){
this.okl = okl;
}

public interface OnKeyDownListener{
/**
* 没有子菜单,直接进入菜单内容
* @param position
*/
public void onKeyDetailListener(int position);
/**
* 还有子菜单,重新绘制子菜单
* @param position
*/
public void onKeyNextListener(int position);
/**
* 返回上一级菜单
* @param position
*/
public void onKeyFrontListener(int position);
/**
* 在顶级菜单中退出菜单
* @param position
*/
public void onKeyCloseListener(int position);
}

}

YoukuMenuActivity.java

package hhf.youku.menu;

import hhf.youku.menu.MenuView.OnKeyDownListener;
import hhf.youku.tools.AppUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
/**
* 主activity
* @author huanghaifeng
*
*/
public class YoukuMenuActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private RelativeLayout menuLinear;
private ImageView sliding,sliding1;
private List<Map<String,Object>> sourceList = new ArrayList<Map<String,Object>>();
private boolean isMenuShow = true;
private MenuView menuView;
private ViewGroup parent;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉Activity的标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu);

// AppUtils.getStatusBarHeight(this);

parent = (ViewGroup) findViewById(R.id.parent);
parent.setOnClickListener(this);

sliding = (ImageView) findViewById(R.id.sliding);
sliding.setOnClickListener(this);

sliding1 = (ImageView) findViewById(R.id.sliding1);
sliding1.setOnClickListener(this);

menuView = (MenuView) findViewById(R.id.menuView);

loadData(0);
menuView.setSourceList(sourceList);
menuView.setOnKeyDownListener(new OnKeyDownListener() {

@Override
public void onKeyNextListener(int position) {
// TODO Auto-generated method stub
Toast.makeText(YoukuMenuActivity.this, "还有子菜单哦~" + position, 0).show();
loadData(1);
menuView.setSourceList(sourceList);
}

@Override
public void onKeyFrontListener(int position) {
// TODO Auto-generated method stub
Toast.makeText(YoukuMenuActivity.this, "返回上一级菜单~" + position, 0).show();
loadData(0);
menuView.setSourceList(sourceList);
}

@Override
public void onKeyDetailListener(int position) {
// TODO Auto-generated method stub
Toast.makeText(YoukuMenuActivity.this, "进入详细界面喽~" + position, 0).show();
Intent in = new Intent(YoukuMenuActivity.this,MainAct.class);
startActivity(in);
}

@Override
public void onKeyCloseListener(int position) {
// TODO Auto-generated method stub
Toast.makeText(YoukuMenuActivity.this, "要关闭菜单?~" + position, 0).show();
}
});
}
/**
* List中第一个数据为中间要显示的数据
* 其他为四周显示的数据
* map中数据:
* bitmap:显示的图片bitmap
* parentId:父id,-1表示一级菜单中间的关闭图标,0表示一级菜单四周的图标
* hasNext: true表示有子菜单,false为没有子菜单进入详细页面
*/
private void loadData(int parentId){
sourceList.clear();
Map<String,Object> map = new HashMap<String,Object>();
if(parentId == 0){
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_camera));
map.put("parentId", "-1");
}else{
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
map.put("parentId", "0");
}

map.put("hasNext", false);
sourceList.add(map);

map = new HashMap<String,Object>();
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_music));
map.put("parentId", "0");
map.put("hasNext", false);
sourceList.add(map);

map = new HashMap<String,Object>();
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_place));
map.put("parentId", "0");
map.put("hasNext", false);
sourceList.add(map);

map = new HashMap<String,Object>();
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_sleep));
map.put("parentId", "0");
map.put("hasNext", true);
sourceList.add(map);

map = new HashMap<String,Object>();
if(parentId == 0){
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_thought));
}else{
System.out.println("ic_launcher~~~~~~~~~");
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
}
map.put("parentId", "0");
if(parentId == 0){
map.put("hasNext", true);
}else{
map.put("hasNext", false);
}
sourceList.add(map);

if(parentId != 0){
map = new HashMap<String,Object>();
map.put("bitmap", BitmapFactory.decodeResource(getResources(), R.drawable.composer_with));
map.put("parentId", "0");
map.put("hasNext", true);
sourceList.add(map);
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.sliding:
if(!isMenuShow){
menuView.startAnimation(MenuAnimations.startAnimationsOut(YoukuMenuActivity.this,
menuView, 1000));
}else{

menuView.startAnimation(MenuAnimations.startAnimationsIn(YoukuMenuActivity.this,
menuView, 1000));
}
isMenuShow = !isMenuShow;
break;
case R.id.sliding1:
Toast.makeText(this, "sliding1", 0).show();
break;
case R.id.parent:
if(isMenuShow){
menuView.startAnimation(MenuAnimations.startAnimationsIn(YoukuMenuActivity.this,
menuView, 1000));
isMenuShow = !isMenuShow;
}
break;
default:
Toast.makeText(YoukuMenuActivity.this, "SLIDING1", 0).show();
break;
}
}
}

MenuView.java(菜单动画(弹出时逐渐变大,关闭时逐渐变小))
package hhf.youku.menu;

import hhf.youku.tools.AppUtils;
import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class MenuAnimations {

public static Animation startAnimationsIn(Context mContext,final View view,int durationMillis) {
AnimationSet set = new AnimationSet(true);

Animation animation1 = new TranslateAnimation(0F,
0F,
0F,
(float)(AppUtils.getScreenRange(mContext)[1])
);
animation1.setFillAfter(true);
animation1.setDuration(durationMillis);
animation1.setInterpolator(new OvershootInterpolator(2F));


Animation animation =new ScaleAnimation(1.0f, //动画起始时 X坐标上的伸缩尺寸

0.0f,//动画结束时 X坐标上的伸缩尺寸

1.0f, //动画起始时Y坐标上的伸缩尺寸

0.0f,//动画结束时Y坐标上的伸缩尺寸

Animation.RELATIVE_TO_SELF,//

0.5f,//动画相对于物件的X坐标的开始位置

Animation.RELATIVE_TO_SELF, //

1.0f);//动画相对于物件的Y坐标的开始位置
animation.setFillAfter(true);
animation.setDuration(durationMillis);
animation.setInterpolator(new OvershootInterpolator(2F));

set.addAnimation(animation);
set.addAnimation(animation1);

set.setAnimationListener(new AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub

}

@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub

}

@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
view.setVisibility(View.GONE);
}
});


view.startAnimation(set);
return set;
}
public static Animation startAnimationsOut(Context mContext,final View view,int durationMillis) {
System.out.println("-----------out ------------------");
view.setVisibility(View.VISIBLE);
AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(0F,
0F,
(float)(AppUtils.getScreenRange(mContext)[1]),
0F
);
animation.setFillAfter(true);
animation.setDuration(durationMillis);
animation.setInterpolator(new OvershootInterpolator(2F));

Animation animation1 =new ScaleAnimation(0.0f, //动画起始时 X坐标上的伸缩尺寸

1.0f,//动画结束时 X坐标上的伸缩尺寸

0.0f, //动画起始时Y坐标上的伸缩尺寸

1.0f,//动画结束时Y坐标上的伸缩尺寸

Animation.RELATIVE_TO_SELF,//

0.5f,//动画相对于物件的X坐标的开始位置

Animation.RELATIVE_TO_SELF, //

1.0f);//动画相对于物件的Y坐标的开始位置
animation1.setFillAfter(true);
animation1.setDuration(durationMillis);
animation1.setInterpolator(new OvershootInterpolator(2F));

set.addAnimation(animation1);
set.addAnimation(animation);

view.startAnimation(set);


return set;
}
}


MainAct.java

package hhf.youku.menu;

import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

/**
* 圆盘菜单
* 花瓣背景
* @author gxc
*
*/
public class MainAct extends Activity implements AnimationListener, OnClickListener {

/**花瓣背景*/
private ImageView img_background;
/**占位按钮*/
private Button tv_1,tv_2,tv_3,tv_4,tv_5;
/**按钮*/
private Button btn_center;
/** X坐标的起始点和终结点,用于判断动画的方向 */
private float startY, endY;
/**屏幕的宽和高*/
int myScreenWidth,myScreenHeight;


/**根据这个值判断中间的那个按钮的背景图片*/
private int position = 0;
/**动画*/
private Animation anim;
/**判断动画是否执行完毕*/
private boolean isEnd=true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉Activity的标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 去掉任务条,获得window对象的setFlags方法,将屏幕布局参数设置为填充整个屏幕
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);

//获取屏幕宽高
WindowManager w=getWindowManager();
Display d=w.getDefaultDisplay();
myScreenWidth=d.getWidth();
myScreenHeight=d.getHeight();

img_background=(ImageView)findViewById(R.id.img_background);
btn_center=(Button)findViewById(R.id.btn_center);
tv_1=(Button)findViewById(R.id.tv_1);
tv_2=(Button)findViewById(R.id.tv_2);
tv_3=(Button)findViewById(R.id.tv_3);
tv_4=(Button)findViewById(R.id.tv_4);
tv_5=(Button)findViewById(R.id.tv_5);

btn_center.setOnClickListener(this);
tv_1.setOnClickListener(this);
tv_2.setOnClickListener(this);
tv_3.setOnClickListener(this);
tv_4.setOnClickListener(this);
tv_5.setOnClickListener(this);

}

/**
* 动画
* @param fromDegrees 起始角度
* @param toDegrees 结束角度
*/
private void myAnim(float fromDegrees, float toDegrees){
//动画声明
anim=new RotateAnimation(fromDegrees, toDegrees,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
//设置动画执行时间
anim.setDuration(1000);
//设置动画执行次数
anim.setRepeatCount(0);
//设置动画渲染器
anim.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_interpolator));
//设置动画结束时停止在结束的位置
anim.setFillAfter(true);
//动画监听
anim.setAnimationListener(this);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
startY = event.getY();
break;
case MotionEvent.ACTION_UP:
endY = event.getY();
float x=event.getX();
if(isEnd==true){//如果动画执行完毕,则允许执行动画
if(x>myScreenWidth/2){//触摸点在屏幕中心右边
if (endY - startY > 10) {// 执行顺时针动画
myAnim(72*position, 72*(position+1));
img_background.startAnimation(anim);
position += 1;
} else if (endY - startY < -10) {// 执行逆时针动画
myAnim(72*position, 72*(position-1));
img_background.startAnimation(anim);
position-=1;
}
}else{//触摸点在屏幕中心左边
if (endY - startY < 10) {// 执行逆时针动画
myAnim(72*position, 72*(position+1));
img_background.startAnimation(anim);
position += 1;
} else if (endY - startY > -10) {// 执行顺时针动画
myAnim(72*position, 72*(position-1));
img_background.startAnimation(anim);
position-=1;
}
}
}
break;
}
return true;
}


@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
isEnd=true;
switch(position%5){//动画结束,设置中间按钮的背景
case 0:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_0);
break;
case 1:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_1);
break;
case 2:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_2);
break;
case 3:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_3);
break;
case 4:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_4);
break;
case -1:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_4);
break;
case -2:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_3);
break;
case -3:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_2);
break;
case -4:
btn_center.setBackgroundResource(R.drawable.btn_background_normal_1);
break;
}
}


@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub

}


@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
isEnd=false;
}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.btn_center:
//这里根据position得知跳转到不同的Activity
switch(position%5){
case 0://演员
Toast.makeText(this, "演员", Toast.LENGTH_SHORT).show();
break;
case 1://剧目
Toast.makeText(this, "剧目", Toast.LENGTH_SHORT).show();
break;
case 2://小品
Toast.makeText(this, "小品", Toast.LENGTH_SHORT).show();
break;
case 3://资讯
Toast.makeText(this, "资讯", Toast.LENGTH_SHORT).show();
break;
case 4://互动
Toast.makeText(this, "互动", Toast.LENGTH_SHORT).show();
break;
case -1://互动
Toast.makeText(this, "互动", Toast.LENGTH_SHORT).show();
break;
case -2://资讯
Toast.makeText(this, "资讯", Toast.LENGTH_SHORT).show();
break;
case -3://小品
Toast.makeText(this, "小品", Toast.LENGTH_SHORT).show();
break;
case -4://剧目
Toast.makeText(this, "剧目", Toast.LENGTH_SHORT).show();
break;
}
break;
case R.id.tv_1:
break;
case R.id.tv_2:
myAnim(72*position, 72*(position+1));
img_background.startAnimation(anim);
position+=1;
break;
case R.id.tv_3:
myAnim(72*position, 72*(position+2));
img_background.startAnimation(anim);
position+=2;
break;
case R.id.tv_4:
myAnim(72*position, 72*(position-2));
img_background.startAnimation(anim);
position-=2;
break;
case R.id.tv_5:
myAnim(72*position, 72*(position-1));
img_background.startAnimation(anim);
position-=1;
break;
}
}

}

AppUtils.java

package hhf.youku.tools;

import java.lang.reflect.Field;

import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;

public class AppUtils {

public static int[] getScreenRange(Context mContext){
int[] ranges = new int[2];
//获取屏幕宽高 ((Activity)mContext).
WindowManager w= ((Activity)mContext).getWindowManager();
Display d=w.getDefaultDisplay();
ranges[0] = d.getWidth();
ranges[1]=d.getHeight()-getStatusBarHeight(mContext)*2;
// getStatusBarHeight(mContext);
return ranges;
}

public static int getStatusBarHeight(final Context mContext){

Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0, sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = mContext.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
Log.e("EXCEPTION","get status bar height fail");
e1.printStackTrace();
}
System.out.println("x = " + x + ",sbar = " + sbar) ;
return sbar;

}

}



设计到的xml布局文件:
main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:id="@+id/parent">


<ImageView
android:id="@+id/img_background"
android:layout_width="320dip"
android:layout_height="320dip"
android:layout_centerVertical="true"
android:background="@drawable/background320" />

<Button
android:id="@+id/btn_center"
android:layout_width="108dip"
android:layout_height="108dip"
android:layout_centerInParent="true"
android:background="@drawable/btn_background_normal_0" />
<!--
这里的Button是占位用的,可见度设为不可见,要想扩大焦点范围就把按钮的宽和高扩大即可
焦点位置可通过改变按钮位置实现改变
这里可用别的控件代替,别如TextView等
-->

<Button
android:id="@+id/tv_1"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_above="@id/btn_center"
android:layout_centerHorizontal="true"
android:layout_marginBottom="35dip"
android:background="#00000000" />

<Button
android:id="@+id/tv_2"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_marginRight="15dip"
android:layout_marginTop="190dip"
android:layout_toLeftOf="@id/btn_center"
android:background="#00000000" />

<Button
android:id="@+id/tv_3"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_below="@id/btn_center"
android:layout_marginLeft="70dip"
android:layout_marginTop="15dip"
android:background="#00000000" />

<Button
android:id="@+id/tv_4"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_below="@id/btn_center"
android:layout_marginLeft="190dip"
android:layout_marginTop="15dip"
android:background="#00000000" />

<Button
android:id="@+id/tv_5"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_marginLeft="15dip"
android:layout_marginTop="190dip"
android:layout_toRightOf="@id/btn_center"
android:background="#00000000" />
</RelativeLayout>

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:id="@+id/parent"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="http://ranfeng0610.blog.163.com/blog/@drawable/ic_launcher"
android:id="@+id/sliding1"
/>
<hhf.youku.menu.MenuView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/menuView"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:src="http://ranfeng0610.blog.163.com/blog/@drawable/ic_launcher"
android:id="@+id/sliding"
/>
</RelativeLayout>