Дети относительного порядка не работают - PullRequest
0 голосов
/ 25 января 2020

Я использую относительный макет в xml и использую два дочерних элемента для макета

Но мой второй дочерний элемент не помещен впереди

Как я могу исправить z-index?

Мой код:

<RelativeLayout
        android:id="@+id/lnrShowList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="false"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="250dp"
        android:layout_marginBottom="50dp"
        android:clickable="true"
        android:gravity="center"
        android:visibility="visible"
        android:layout_alignParentEnd="true">

        <carbon.widget.LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="false"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="15dp"
            android:layout_marginRight="20dp"
            android:layout_marginBottom="20dp"
            android:background="@color/colorBgWhite"
            android:clickable="false"
            android:gravity="center"
            android:orientation="vertical"
            app:carbon_cornerRadius="16dp"
            app:carbon_elevation="@dimen/elevation"
            app:carbon_elevationShadowColor="@color/colorShadow">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="15dp"
                android:fontFamily="@font/sahel_font"
                android:gravity="right"
                android:text="مشاهده لیست همه نتایج یافت شده"
                android:textColor="#787878"
                android:textSize="11dp" />

        </carbon.widget.LinearLayout>

        <LinearLayout
            android:id="@+id/arrowGo"
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:layout_alignParentTop="true"
            android:layout_centerInParent="true"
            android:background="@drawable/showlist_bg_gray"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="22dp"
                android:layout_height="22dp"
                android:layout_gravity="center"
                android:adjustViewBounds="false"
                android:background="@drawable/up" />
        </LinearLayout>

    </RelativeLayout>

В другом макете z-index с элементом работает нормально, но для этого xml не работает

Даже я меняю относительный макет на макет ограничения, но не работаю!

Эта проблема, когда шоу я использую carbon Экран:

enter image description here

Ответы [ 2 ]

1 голос
/ 25 января 2020

Чтобы достичь этого, вы должны установить больше elevation в вашем втором дочернем макете RelativeLayout. Например,

Установите elevation на 10dp в вашем carbon.widget.LinearLayout

app:carbon_elevation="10dp"

И установите elevation на 11dp в своем LinearLayout

app:elevation="11dp"
1 голос
/ 25 января 2020

Есть два способа решить эту проблему.

  1. yourView.bringToFront(); Это выводит ваш макет arrowGo вперед, используя java.
  2. , изменяющий порядок ваших макетов. , так что arrowGo выше LinearLayout
...