【发布时间】:2019-07-14 18:36:39
【问题描述】:
目前,我有这个页面的代码。
但我的预览应该是我的按钮位于后半部分布局的中心,但在我的模拟器中,它仍显示在布局的顶部。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_profile">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_img"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/default_person_icon"
app:civ_border_color="@android:color/black"
app:civ_border_width="2dp"
android:layout_centerInParent="true"
android:layout_marginTop="100dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Email"
android:textSize="28sp"
android:textColor="@android:color/white"
android:layout_below="@+id/profile_img"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<Button
android:id="@+id/btn_change_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Change Password"
app:cornerRadius="50dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"/>
<Button
android:id="@+id/btn_sign_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign Out"
app:cornerRadius="50dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"/>
</LinearLayout>
</LinearLayout>
这里是预览图
https://i.stack.imgur.com/QLaot.jpg
这是模拟器的图像
【问题讨论】: