如何在约束布局中将一个相对布局放在另一个布局下?

时间:2017-08-24 18:10:38

标签: android android-layout android-fragments android-relativelayout android-constraintlayout

我正在考虑在约束布局中将一个relativelayout放在另一个下面,而在底部放置另一个按钮容器覆盖容器。我该怎么办呢? 这是代码:

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/activeSpeakerContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/groupCallerList"
        app:layout_constraintTop_toBottomOf="@+id/callStatusContainer"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">

        <FrameLayout
            android:id="@+id/activeSpeakerVideo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/black" />

        <ImageView
            android:id="@+id/activeSpeakerImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="48dp"
            android:src="@drawable/call_default_profile" />

        <ImageView
            android:id="@+id/beta_calling_watermark"
            android:layout_width="130dp"
            android:layout_height="28dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="36dp"
            android:layout_marginLeft="16dp"
            android:src="@drawable/ic_beta_calling_watermark_blue" />

        <TextView
            android:id="@+id/activeSpeakerName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="#AA555555"
            android:ellipsize="end"
            android:gravity="center_horizontal|bottom"
            android:lines="1"
            android:textSize="16sp"
            tools:text="" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/ShareContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/callButtonContainer"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <FrameLayout
            android:id="@+id/ShareVideo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/black"/>

        <ImageButton
            android:id="@+id/ShareToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="36dp"
            android:layout_marginLeft="16dp"
            android:background="@android:color/transparent"
            android:src="@drawable/ic_video_cam_switch" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/callStatusContainer"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#AA555555"
        android:padding="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/callNameText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:ellipsize="end"
            android:lines="1"
            android:textSize="14sp"
            tools:text="" />

        <TextView
            android:id="@+id/callParticipantCountText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/callNameText"
            android:layout_toRightOf="@+id/callNameText"
            android:ellipsize="end"
            android:lines="1"
            android:paddingLeft="18dp"
            android:paddingRight="18dp"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/callDurationText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_toEndOf="@id/callParticipantCountText"
            android:layout_toLeftOf="@+id/callButtonVideoRotate"
            android:layout_toRightOf="@id/callParticipantCountText"
            android:layout_toStartOf="@id/callButtonVideoRotate"
            android:lines="1"
            android:textSize="14sp"
            tools:text="03:16" />

        <ImageButton
            android:id="@+id/callButtonVideoRotate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/callDurationText"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="@android:color/transparent"
            android:src="@drawable/ic_video_cam_switch" />

    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/groupCallerList"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="invisible"
        app:layout_constraintBottom_toTopOf="@+id/callButtonContainer"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/activeSpeakerContainer">

    </android.support.v7.widget.RecyclerView>

    <RelativeLayout
        android:id="@+id/callProgressContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="@+id/groupCallerList"
        app:layout_constraintLeft_toLeftOf="@+id/groupCallerList"
        app:layout_constraintRight_toRightOf="@+id/groupCallerList"
        app:layout_constraintTop_toTopOf="@+id/groupCallerList">

        <TextView
            android:id="@+id/callProgressName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dp"
            android:gravity="center_horizontal"
            android:textSize="20sp"
            tools:text="Caller Name" />

        <TextView
            android:id="@+id/callProgressText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/callProgressName"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dp"
            android:gravity="center_horizontal"
            android:text="@string/call_status_connecting"
            android:textSize="16sp" />

    </RelativeLayout>

    <include
        android:id="@+id/callButtonContainer"
        layout="@layout/layout_call_button_bar_1_row"
        android:layout_width="0dp"
        android:layout_height="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />


    <android.support.constraint.ConstraintLayout
        android:id="@+id/callButtonContainerUnavailable"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/callButtonContainer"
        app:layout_constraintLeft_toLeftOf="@+id/callButtonContainer"
        app:layout_constraintRight_toRightOf="@+id/callButtonContainer"
        app:layout_constraintTop_toTopOf="@+id/callButtonContainer"
        tools:visibility="visible">

        <Button
            android:id="@+id/callButtonCancel"
            style="@style/CallButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableTop="@drawable/btn_call_end"
            android:text="@string/dialog_button_cancel"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="@+id/callButtonRetry"
            app:layout_constraintTop_toTopOf="parent" />

        <Button
            android:id="@+id/callButtonRetry"
            style="@style/CallButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableTop="@drawable/btn_call_retry"
            android:text="@string/button_try_again"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toRightOf="@+id/callButtonCancel"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

任何线索如何去做?我实际上想将callstatuscontainer放在share或activespeaker容器之上。我试过app:layout_constraintTop_toBottomOf =&#34; @ + id / callStatusContainer&#34;  在有源扬声器容器,但没有运气,任何想法?

0 个答案:

没有答案