Поместите FrameLayout поверх каждого View - PullRequest
0 голосов
/ 02 января 2019

У меня есть этот макет:

<android.support.v7.widget.CardView
    android:id="@+id/description_root_View"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    app:cardCornerRadius="@dimen/CardView_CornerRadius"
    app:cardElevation="@dimen/CardView_elevation"
    app:cardUseCompatPadding="true"
    android:background="@color/escription_background"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="@id/SwipeView">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/View_margins">

        <FrameLayout
            android:id="@+id/description_FrameLayout_profile"
            android:layout_width="@dimen/description_FrameLayout_profile"
            android:layout_height="@dimen/description_FrameLayout_profile"
            android:background="?selectableItemBackground"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/description_ImageView_profile"
                android:layout_width="@dimen/description_ImageView_profile"
                android:layout_height="@dimen/description_ImageView_profile"
                android:src="@drawable/profile_photo"
                android:scaleType="fitCenter"
                android:layout_gravity="center"/>

            </FrameLayout>

    </android.support.constraint.ConstraintLayout>

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

   <View
    android:id="@+id/View_layer_over"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:background="@color/fragment_tutorial_layer_background"
    android:elevation="@dimen/adapter_versus_CardView_elevation"
    android:clickable="true"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

В начале View View_layer_over является полупрозрачным видом, который находится поверх всего в моем макете.Когда я нажимаю кнопку, я хочу вывести description_FrameLayout_profile FrameLayout поверх View_layer_over View.Я попробовал метод View.bringToFront() и ViewCompat.setTranslationZ(), после того как они оба назвали Parent.invalidate(), но ни один из них не работал для меня.Я думаю, что это как-то связано с атрибутом высоты.

Любая помощь будет принята с благодарностью.Спасибо!

1 Ответ

0 голосов
/ 02 января 2019

Я не уверен на 100%, что я точно понимаю, что вы хотите, но в этой ситуации я бы сделал, чтобы ConstraintLayout был представлением родительского / корневого типа, которое содержало бы ваше представление View_layer_over и ваше CardView.Если вы правильно установите свои ограничения, вы получите поведение, которое, я думаю, вам нужно ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...