2017-09-14 63 views
-4

我想顯示在的LinearLayout和圖像 This is how my layout should look like如何修復的ImageView過的LinearLayout

我創造了我的佈局是這樣,

<?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> 

我應該怎麼我的代碼更改的地方如圖所示,在Linearlayout頂部的imageview,幫助我獲得我想要的精確視圖

+2

使用'RelativeLayout'或'FrameLayout'。 – Piyush

回答

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" /> 

0

試試這個:

<?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: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_marginTop="75dp" 
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_centerHorizontal="true" 
android:src="@drawable/success_icon" /> 
</RelativeLayout> 
相關問題