Android – 如何动态更改片段布局

前端之家收集整理的这篇文章主要介绍了Android – 如何动态更改片段布局前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个平板电脑应用程序,其中包含显示我公司数据的片段.我想在页面上进行动态更改我的布局与屏幕方向,但我还没有找到.

如果有人得到解决方案,请提前感谢

解决方法

@Yume177,我发现了怎么做:
  1. @Override
  2. public void onConfigurationChanged(Configuration newConfig) {
  3. // TODO Auto-generated method stub
  4. super.onConfigurationChanged(newConfig);
  5. RelativeLayout rl = (RelativeLayout) findViewById(R.id.about);
  6. rl.removeAllViews();
  7. rl.addView(View.inflate(myView.getContext(),R.layout.about,null));
  8. }

我有两个名为“about.xml”的RelativeLayout,在dir res / layout-sw720dp / about.xml中有一个布局,我的drawable用于纵向模式,res / layout-sw720dp-land / about.xml用我的landscape drawable.当我旋转平板电脑时,我的布局非常合适.希望我会帮助你

猜你在找的Android相关文章