当我们旋转屏幕时如何使android布局相同

时间:2017-08-17 16:57:31

标签: android orientation

当我们更改方向或旋转屏幕时,我的xml中有两个recyclerview,布局会更改如何使布局相同而不是更改布局

2 个答案:

答案 0 :(得分:0)

试试这个,它将你的屏幕划分为纵向和横向模式两部分

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="2"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        />

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        />
</LinearLayout>

答案 1 :(得分:0)

我不完全确定你在问什么。但是我理解的是。

  1. 使用LinearLayout,里面有两个recyclerview并根据weight属性给出高度= .5; 就像这样::

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        />
    
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        />                
    

  2. 制作该布局的横向版本并执行与上述相同的操作。最简单的方法是转到xml的GUI屏幕,在语言选项卡的右侧,选择Layout Variats选项卡,选择创建横向变体。

相关问题