无法在低于3.0 android的设备上移动屏幕内容
我需要移动左侧的屏幕内容,以便使用此代码 获取内容无法在低于3.0 android的设备上移动屏幕内容,android,layout,Android,Layout,我需要移动左侧的屏幕内容,以便使用此代码 获取内容 try { content = ((LinearLayout) act.findViewById(android.R.id.content) .getParent()); } catch (ClassCastException e) { /* * When there is no title bar * (android:theme="@
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);
}
我注意到,在安卓>3.0的设备上,内容集位于try块中,而在<3.0的设备上,内容集位于catch块中。
在这里,我移动内容:
FrameLayout.LayoutParams pr = (android.widget.FrameLayout.LayoutParams) content
.getLayoutParams();
pr.rightMargin = menuSize;
pr.leftMargin = -menuSize;
content.setLayoutParams(pr);
因此,在设备>3.0上,所有功能都很好。我移动了内容。在设备上,发现如果未设置重力,答案框架布局将不会考虑边距