sup*_*g22 0 xml user-interface android android-linearlayout android-relativelayout
我正在尝试创建一个看起来像这样的简单UI
我是android的新手,并且一直在尝试不同类型的布局(线性/相对),我相信Linear可能是这里的方式(我希望在某个阶段使ListViews的数量动态,但现在2很好) .
我应该使用线性布局或相对布局,还是两者的某种组合来实现此目的.
这是我拥有的XML,即使它的重力设置为正确,我似乎无法使按钮正确对齐.我愿意接受有关如何解决此问题的任何建议,或者是否有更好的方法
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9"
android:orientation="horizontal" >
<ListView
android:id="@+id/lv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
/>
<ListView
android:id="@+id/lv2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="New Button"
android:id="@+id/button"
android:gravity="right" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:这是UI目前的样子
好的,你可以做一件事.
<RelativeLayout>
<LinearLayout> <!-- horizontal orientation with weightsum 2 -->
<LinearLayout> <!-- vertical orientation with layout weight 1 and width 0dp -->
</LinearLayout>
<LinearLayout> <!-- vertical orientation with layout weight 1 and width 0dp -->
</LinearLayout>
</LinearLayout>
<Button /> <!-- alignParentBottom = true and alignParentLeft = true -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)