您好,我必须使用常规Android布局创建UI,如下图所示(附图)。我得到了页眉,页脚和中间区域以及图像视图。 根据画面:区域A和区域C是类似的高度(屏幕的20%)和图像视图应该总是在B区和C区的中间 Android布局在另外两个布局的中间放置一个布局
我的当前xml代码是这样被放置
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/show_contact_bottomArea"
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:id="@+id/show_contact_middleArea"
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:background="@color/grayContact"
android:layout_below="@+id/show_contact_headerArea"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/show_contact_bottomArea">
</LinearLayout>
<LinearLayout
android:id="@+id/show_contact_headerArea"
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"></LinearLayout>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
app:srcCompat="@drawable/common_google_signin_btn_icon_dark_focused"
android:id="@+id/imageView2"
android:layout_marginBottom="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
我给
marginBot tom =“40dp”
图像视图向上推,这不是一个好的做法。将图像视图放置在区域B和区域C边界的中心的最佳方式是什么?
也是目前我给
机器人:layout_height = “120dp”
为A区& B区的高度,但最好都应该是在屏幕上,怎样的20%(每个)实现呢?
使用的FrameLayout。它对这些种类或要求灵活 – Stallion