我在左侧放了菜单栏(类似于底部菜单栏),右侧放内容页设置如下,但是内容页还是靠左的,内容会覆盖掉菜单按钮,应该怎样将右侧的内容页向右移动菜单栏的宽度呢?求指教
public static final int bottom_layoutWidth = 60;//菜单栏宽度
private void resizeLayout() {
View customView = getChildAt(0);//右侧内容
android.view.ViewGroup.LayoutParams params = customView.getLayoutParams();
int screenWidth = GlobalUtils.getInstance().getScreenWidth(); //获取屏幕宽度
int lessWidth = screenWidth - bottom_layoutWidth;
params.width = lessWidth;
customView.setPadding(bottom_layoutWidth, 0, 0, 0);
customView.setLayoutParams(params);
}
内容页的宽度确实减去了菜单栏的宽度,但是它是靠左的,右边有一部分就空着了,而内容却会覆盖掉菜单栏android布局菜单
public static final int bottom_layoutWidth = 60;//菜单栏宽度
private void resizeLayout() {
View customView = getChildAt(0);//右侧内容
android.view.ViewGroup.LayoutParams params = customView.getLayoutParams();
int screenWidth = GlobalUtils.getInstance().getScreenWidth(); //获取屏幕宽度
int lessWidth = screenWidth - bottom_layoutWidth;
params.width = lessWidth;
customView.setPadding(bottom_layoutWidth, 0, 0, 0);
customView.setLayoutParams(params);
}
内容页的宽度确实减去了菜单栏的宽度,但是它是靠左的,右边有一部分就空着了,而内容却会覆盖掉菜单栏android布局菜单
解决方案 »
- 关于android4.0+长按Home键的操作
- 如何让自己注册的BroadcastReceiver可以一直监听
- android导入现存数据库出IO异常
- 求Android实战开发项目的视频~~~
- 菜鸟 求助R.layout.dialog_view 为什么我点不出来,手写上去报错啊
- 关于Android上的ffmpeg license兼容问题
- 找android的工作,希望给点建议
- FindClass 找不到类
- 安卓开发,代码没有报错但是Logcat一片红!
- Android中如何让Activity悬浮在手机屏幕上
- Android UDP setReceiveBufferSize
- android 自己根据实例activity类和xml关联运行时报错是怎么回事
或者
customView.scrollBy(bottom_layoutWidth);
试试
非常感谢您的回答
使用customView.setTranslationX(bottom_layoutWidth);的时候在他的下一行的末尾出现红色波浪线报错
customView.scrollBy(bottom_layoutWidth);也只是把右边部分的内容移动了