кнопка вывести на передний план, имея два - PullRequest
0 голосов
/ 16 ноября 2018

Я пытаюсь реализовать следующий дизайн на Android.enter image description here

Я знаю, что для того, чтобы кнопка была в этом положении, у меня должно быть два макета ограничений;один для всей формы смены пароля и один для формы смены пароля без кнопки «Сохранить», а затем установите для кнопки «Сохранить» верхнее и нижнее ограничение на второе ограничение-ограничение.Но когда я делаю это, кнопка идет позади формы, и вот проблема enter image description here

вот мой xml:

    <android.support.design.widget.CoordinatorLayout 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"
        tools:context=".ChangePasswordActivity">

        <include
            android:id="@+id/changePasswordBar"
            layout="@layout/top_bar_full"></include>

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">


            <android.support.constraint.ConstraintLayout
                android:id="@+id/changePasswordCTL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activities_constraint_top_bottom"
                android:layout_marginEnd="@dimen/activities_constraint_start_end"
                android:layout_marginStart="@dimen/activities_constraint_start_end"
                android:layout_marginTop="@dimen/activities_constraint_top_bottom"
                android:background="@drawable/radius_background_exchange"
                android:elevation="5dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                // some EditText and TextView views here


            </android.support.constraint.ConstraintLayout>

    <br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
                android:id="@+id/changePasswordBT"
                style="@style/customButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="32dp"
                android:layout_marginStart="32dp"
                android:layout_marginTop="8dp"
                android:fontFamily="@font/sans_web_medium"
                android:text="@string/finish"
                android:textAllCaps="false"
                android:textColor="@android:color/white"
                android:textSize="@dimen/signinup_button_font_size"
                app:initialCornerAngle="5dp"
                app:layout_constraintBottom_toBottomOf="@+id/changePasswordCTL"
                app:layout_constraintEnd_toEndOf="@+id/changePasswordCTL"
                app:layout_constraintStart_toStartOf="@+id/changePasswordCTL"
                app:layout_constraintTop_toBottomOf="@+id/changePasswordCTL"
                app:spinning_bar_color="@android:color/white"
                app:spinning_bar_padding="6dp"
                app:spinning_bar_width="4dp" />

        </android.support.constraint.ConstraintLayout>

    </android.support.design.widget.CoordinatorLayout>

Ответы [ 3 ]

0 голосов
/ 16 ноября 2018

Вы можете достичь такого дизайна, используя CoordinatorLayout.

Пример:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <ImageView
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:background="@color/primary" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_camera"
        app:layout_anchor="@id/header"
        app:layout_anchorGravity="bottom|center_horizontal" />

</android.support.design.widget.CoordinatorLayout>

enter image description here

просто используйте следующее дляпривязать макет вашей кнопки к макету представления вашей библиотеки:

app:layout_anchor= "id_of_password_form_layout"
0 голосов
/ 16 ноября 2018

На форме есть отметка 5dp, а на кнопке отметка отсутствует, поэтому она частично скрыта.Увеличьте высоту кнопки как минимум до 5dp.

android:elevation="5dp"
0 голосов
/ 16 ноября 2018

Когда elevation отсутствует на рисунке, представления, определенные позже в файле XML, будут отображаться «поверх» представлений, определенных ранее.Тем не менее, ваша форма пароля имеет android:elevation="5dp", и это отменит обычный порядок рисования.

Чтобы исправить, добавьте также повышение прав на кнопку.android:elevation="5dp" должно быть достаточно, с тех пор они находятся на одной высоте, и должны применяться нормальные правила.Но вы могли бы повысить его, чтобы гарантировать, что он всегда отображается поверх формы пароля.

...