【发布时间】:2013-07-24 08:45:07
【问题描述】:
我有一个平板电脑应用程序,其中包含显示我公司数据的 about 片段。我想在页面上使用屏幕方向动态更改布局,但我还没有找到。
如果有人得到解决方案,在此先感谢
【问题讨论】:
标签: android android-layout android-fragments android-screen
我有一个平板电脑应用程序,其中包含显示我公司数据的 about 片段。我想在页面上使用屏幕方向动态更改布局,但我还没有找到。
如果有人得到解决方案,在此先感谢
【问题讨论】:
标签: android android-layout android-fragments android-screen
@Yume177,我找到了方法:
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.about);
rl.removeAllViews();
rl.addView(View.inflate(myView.getContext(), R.layout.about, null));
}
我有 2 个名为“about.xml”的 RelativeLayout,其中一个布局在目录 res/layout-sw720dp/about.xml 中,我的可绘制用于纵向模式和 res/layout -sw720dp-land/about.xml 与我的风景画。当我旋转我的平板电脑时,我的布局非常适合。希望能帮到你
【讨论】:
如果您使用的是 ABS + viewpager,那会有点困难(如果您找到解决方案,我很感兴趣!请参阅我的最后一个问题)
这是官方文档 http://developer.android.com/training/basics/fragments/fragment-ui.html
http://developer.android.com/guide/practices/tablets-and-handsets.html
http://developer.android.com/guide/practices/screens_support.html
【讨论】: