androidbuttonlayoutcover

How to hide buttons under layout


I have a RelativeLayout as parent layout.In it i've got two buttons and a FrameLayout.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="button 1"
    />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="button 2"
    android:layout_below="@+id/button1"/>

<FrameLayout
    android:background="@color/blue"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</FrameLayout>

screenshot

The FrameLayout has both width and height as match_parent but I don't understand why it doesn't cover the buttons.

How can i cover the buttons ?


Solution

  • It seems that the buttons have an attribute called stateListAnimator.

    So what you have to do is make another layout file(v21) for lollipop or higher versions and add this in your button xml:

    android:stateListAnimator="@null"
    

    For lower versions of Android it seems to work like this:

    android:stateListAnimator="@null"
    tools:ignore="UnusedAttribute"