JustCurious
JustCurious

Reputation: 65

How to dim the background of a custom layout?

I have created a custom layout which extends viewgroup in order to implement a sliding menu similar to the one in this video at 1:18: https://www.youtube.com/watch?v=YeR7McJIltk

However, what I don't know how to do is dim the background content when the menu is sliding in.

Upvotes: 1

Views: 2319

Answers (2)

Sriraksha
Sriraksha

Reputation: 569

Give background like this. android:background="#8000"

Upvotes: 0

Divers
Divers

Reputation: 9569

You can do something like that:

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

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1">
        //your views are here

    </LinearLayout>

    <View
        android:id="@+id/dim"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#cc000000" />

</RelativeLayout>

And make your dim FrameLayout visible only when menu is opened, and invisible when it closed

Upvotes: 4

Related Questions