Android如何桌面布局,如何在屏幕外移动布局内容android

我需要将屏幕内容移到左侧,这样我就可以为右侧的幻灯片菜单腾出空间

这是代码:

// modify content layout params

try {

content = ((LinearLayout) act.findViewById(android.R.id.content)

.getParent());

} catch (ClassCastException e) {

/*

* When there is no title bar

* (android:theme="@android:style/Theme.NoTitleBar"), the

* android.R.id.content FrameLayout is directly attached to the

* DecorView, without the intermediate LinearLayout that holds the

* titlebar plus content.

*/

content = (FrameLayout) act.findViewById(android.R.id.content);

}

FrameLayout.LayoutParams pr = (android.widget.FrameLayout.LayoutParams) content

.getLayoutParams();

pr.rightMargin = menuSize;

content.setLayoutParams(pr);

// add the slide menu to parent

parent = (FrameLayout) content.getParent();

try {

parent = (FrameLayout) content.getParent();

} catch (ClassCastException e) {

/*

* Most probably a LinearLayout, at least on Galaxy S3.

*/

LinearLayout realParent = (LinearLayout) content.getParent();

parent = new FrameLayout(act);

realParent.addView(parent, 0); // add FrameLayout to real parent of

// content

realParent.removeView(content); // remove content from real parent

parent.addView(content); // add content to FrameLayout

}

LayoutInflater inflater = (LayoutInflater) act

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

menu = inflater.inflate(R.layout.slidemenu, null);

FrameLayout.LayoutParams lays = new FrameLayout.LayoutParams(menuSize,

FrameLayout.LayoutParams.MATCH_PARENT, Gravity.RIGHT);

lays.setMargins(0, statusHeight, 0, 0);

menu.setLayoutParams(lays);

parent.addView(menu);

但我得到的是:

内容只是调整大小以适应屏幕,我该如何使这项工作?

顺便说一句,我不能修改内容布局它的相对布局与surfaceview,但它应该适用于任何布局,因为我修改DecorView是顶视图容器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值