简体   繁体   English

如何在Android中更改顶部布局?

[英]How to change top layout in android?

When I need to change an activity skin, can I change top layout while maintaining the activity? 当我需要更改活动皮肤时,可以在维持活动的同时更改顶部布局吗?

like... change orientation of display. 像...更改显示方向。

For example, 例如,

I have 1 activity file, 我有1个活动档案,
MainActivity.java

and I have 2 layout xmls, 我有2个布局xml,
main_a.xml main_b.xml main_a.xml main_b.xml

My start activity is main_a.xml 我的开始活动是main_a.xml

In this situation, Can I change layout as main_b.xml programmatically? 在这种情况下,可以main_b.xml编程将布局更改为main_b.xml吗?

Easy 简单

setContentView(main_b.xml);

If you have 2 different layouts for portrait and landscape - it is even easier - just place landscape layout file into layout-land folder (not layout ) - and your layout will be applied automatically during orientation change 如果您有2种不同的纵向和横向布局-甚至更容易-只需将横向布局文件放置到layout-land文件夹(不是layout )中,并且您的布局将在方向更改时自动应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM