我将此滑动菜单用作库。我想要2个不同大小的菜单。 我有一个问题:当我推大一个时,另一个会随之移动
我改变了我的main.java,在lef和右边有两个不同尺寸的菜单
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Hello");
// set the content view
setContentView(R.layout.main);
// configure the SlidingMenu
final SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
DisplayMetrics display = this.getResources().getDisplayMetrics();
int width = display.widthPixels;
int menu_width = width - width / 3;
if (menu_width < 100) {
menu_width = 100;
}
menu.setBehindWidth(menu_width);
menu.setFadeDegree(0.35f);
menu.setSlidingEnabled(true);
menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
menu.setSlidingEnabled(true);
View view = G.layoutInflater.inflate(R.layout.menu, null);
menu.setMenu(view);
final SlidingMenu menu2 = new SlidingMenu(this);
menu2.setMode(SlidingMenu.RIGHT);
menu2.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu2.setBehindWidth(menu_width / 2);
menu2.setFadeDegree(0.35f);
menu2.setSlidingEnabled(true);
menu2.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
menu2.setSlidingEnabled(true);
View view22 = G.layoutInflater.inflate(R.layout.menu, null);
menu2.setMenu(view22);
}
答案 0 :(得分:1)
为什么你使用两个sligingMenu代替你的SlidingMenu
尝试LEFT_RIGHT模式这个类的方法为setMode()
LEFT_RIGHT_ACTIVITY
答案 1 :(得分:0)
你可以使用这样的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Hello");
// set the content view
setContentView(R.layout.main);
// configure the SlidingMenu
final SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
/// get 1/3 screen width
DisplayMetrics display = this.getResources().getDisplayMetrics();
int width = display.widthPixels;
int menu_width = width - width / 3;
if (menu_width < 100) {
menu_width = 100;
}
menu.setBehindWidth(menu_width); // set the first sliding size
menu.setFadeDegree(0.35f);
menu.setSlidingEnabled(true);
menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
menu.setSlidingEnabled(true);
View view = G.layoutInflater.inflate(R.layout.menu, null);
menu.setMenu(view);
final SlidingMenu menu2 = new SlidingMenu(this);
menu2.setMode(SlidingMenu.RIGHT);
menu2.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu2.setBehindWidth(menu_width / 2); // set the second sliding size half of first slidingه
menu2.setFadeDegree(0.35f);
menu2.setSlidingEnabled(true);
menu2.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
menu2.setSlidingEnabled(true);
View view22 = G.layoutInflater.inflate(R.layout.menu, null);
menu2.setMenu(view22);