Перенесите вид спереди на MaterialCardView и ConstraintLayout с повышением - PullRequest
0 голосов
/ 26 сентября 2018

в моем макете, который содержит MaterialCardView я хочу добавить app:cardElevation="10dp".

enter image description here

Но когда я применяю cardElevation, моя кнопка портится.

enter image description here

Я пробовал много предложений из других вопросов, таких как добавление огромного количества возвышений к кнопке или изменение порядка Z, но это не работает.

    ViewCompat.setElevation(button, 1000.0f)
    ViewCompat.setTranslationZ(button, 1000.0f)
    button.bringToFront()
    login_card.invalidate()

Есть идеи?

Полный формат XML Формат XML (сокращенный):

<com.google.android.material.card.MaterialCardView
    android:id="@+id/login_card"
    android:layout_width="match_parent"
    app:cardElevation="10dp i'm breaking the layout-----------"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

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

        <com.google.android.material.textfield.TextInputLayout
        ...
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
        ...
        </com.google.android.material.textfield.TextInputLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

<androidx.appcompat.widget.AppCompatButton
    android:id="@+id/login_button_login"
    android:layout_width="@dimen/login_button_width"
    android:layout_height="wrap_content"
    app:elevation="1000dp"
    android:text="@string/login_button_login"
    app:layout_constraintBottom_toBottomOf="@id/login_card"
    app:layout_constraintEnd_toEndOf="@+id/login_card"
    app:layout_constraintStart_toStartOf="@+id/login_card"
    app:layout_constraintTop_toBottomOf="@+id/login_card"
    app:layout_constraintVertical_bias="1" />

...