When there are many layouts by layer in XML, can I set the priority of the background set for each layout?

Asked 2 years ago, Updated 2 years ago, 128 views

<LinearLayout"
    background = "@drawable/radius">
    <Layout
           background = "@color/white"/>
    <Layout
           background = "@color/black"/>

</LinearLayout>

If you have an xml file like the one above

Can we prioritize like layer-list? Should I say overdraw? I want the entire frame of the screen to have radius I hope the interior background is half white and half black.

But when you apply it like this, the colors that are set in the interior layout I think it's covering the background value of the upper layout, and it doesn't even apply radius.

I can't use the background Tint because the lower version has to be compatible, so what's the way? ㅠ<

android android-widget

2022-09-22 11:13

1 Answers

I understood the priority as z-index. The z-index is set in the order in which it is added within the container layout (Root view).

<FrameLayout    
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ... />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        .../>
</FrameLayout>

For example, in the above code, ImageView is drawn higher (z-index higher) than ImageView. Other than this rule, there is no other way to adjust the z-index in XML.

Although the following functions exist on the code, it seems difficult to handle what you want even if you set them up.

A common approach is to create a border drawable like the link below and make it the background of the layout.


2022-09-22 11:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.