我想在线性布局上显示图像 This is how my layout should look like
我创建了这样的布局,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="10dp">
<ImageView
android:id="@+id/anim_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/success_icon" />
<LinearLayout
android:id="@+id/anim_layout"
android:layout_width="280dp"
android:layout_height="200dp"
android:background="@color/grayBackground"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="25dp"
android:layout_weight="1.5"
android:gravity="center_horizontal"
android:text="Success"
android:textColor="@color/lightFont"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Check you email for booking\nconfirmation We'll see you soon"
android:textSize="18sp" />
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:background="@color/cardview_dark_background"
android:text="OK"
android:textColor="@color/progressWhite"
android:textSize="16dp" />
</LinearLayout>
我应该如何更改代码以将imageview置于Linearlayout之上,如图所示,帮助我获得我想要的精确视图
答案 0 :(得分:0)
使用 RelativLayout
尝试此操作<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="10dp">
<LinearLayout
android:id="@+id/anim_layout"
android:layout_width="280dp"
android:layout_height="200dp"
android:background="@color/grayBackground"
android:gravity="center"
android:layout_centerInParent="true"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="25dp"
android:layout_weight="1.5"
android:gravity="center_horizontal"
android:text="Success"
android:textColor="@color/lightFont"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="Check you email for booking\nconfirmation We'll see you soon"
android:textSize="18sp" />
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:background="@color/cardview_dark_background"
android:text="OK"
android:textColor="@color/progressWhite"
android:textSize="16dp" />
</LinearLayout>
<ImageView
android:id="@+id/anim_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:src="@drawable/success_icon" />
答案 1 :(得分:0)
试试这个:
RasterStack