适应横竖屏切换的问题
大家好,我一直做横屏或者竖屏的布局,没有做过横竖屏切换的布局,很多网上说把布局文件写两份,感觉这个固然有些好处,但是什么都要实现两份,大家有没有好的办法或者例子,敬请分享
[解决办法]
有个比较“懒”的方法,用ScrollView,这样只需要写竖屏的布局,横屏的时候也是一样,但是可以上下滑动。
ScrollView写在你的布局的最外层即可。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout android:id="@+id/editors"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
。。。。。。。。。
</LinearLayout>
</ScrollView>