簡體   English   中英

如何在兩個布局之間約束圖像的中心 android

[英]How to constraint the center of an image between two layouts android

我需要按照屏幕截圖所示進行操作,但我不明白該怎么做。 我試圖與baseline連接,但它沒有用。

我的代碼在這里:

<androidx.constraintlayout.widget.ConstraintLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/rl_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    </RelativeLayout>

    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/top_layout"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:background="@color/white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/rl_bar">

    </androidx.appcompat.widget.LinearLayoutCompat>

    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/bottom_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/elegant_black"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/top_layout">

    </androidx.appcompat.widget.LinearLayoutCompat>

    <de.hdodenhof.circleimageview.CircleImageView
        android:src="@color/elegant_black"
        app:layout_constraintBaseline_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

我怎樣才能做到這一點?

截圖示例:

在此處輸入圖像描述

這就是我得到的:

在此處輸入圖像描述

這里我們 go。 嘗試這個。 干杯。

    <de.hdodenhof.circleimageview.CircleImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginStart="20dp"
        android:background="@color/elegant_black"
        app:civ_border_color="@android:color/white"
        app:civ_border_width="2dp"
        app:layout_constraintBottom_toTopOf="@id/bottom_layout"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/top_layout" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM