0

I am displaying my SlidingDrawer on the main screen using the WindowManager object. I am facing difficulty in changing the height of the sliding drawer programmatically, because of which the elements which are behind the drawer are not clickable. I have read the Questions on this topic but none of them is giving me the desired result.

Note: i just want to change the height of the sliding drawer element.

Java Code

                final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                    PixelFormat.TRANSLUCENT);




            windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            //params.x = 0;                params.y = 0;


            windowManager.addView(view1, params);

Xml Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="wrap_content"
android:layout_height="wrap_content">

<SlidingDrawer
    android:id="@+id/drawer"
    android:layout_width="70dp"
    android:layout_height="wrap_content"
    android:content="@+id/content"
    android:handle="@+id/image">

    <ImageView
        android:id="@+id/image"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/handle2" />

    <GridView
        android:id="@+id/content"
        android:layout_width="70dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@color/black_trans"></GridView>


</SlidingDrawer>

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Anuj Arora
  • 21
  • 8

1 Answers1

0

You can refer to this link How to change the height of the drawer

android:layout_marginTop="50dip"

Aliy
  • 406
  • 6
  • 21
  • So does it mean, i set the height to match_parent and then increase or decrease the top_margin?@Aliy – Anuj Arora Dec 31 '17 at 14:25
  • Yes try setting layout_marginTop of your sliding drawer in the XML file. Hope this works – Aliy Dec 31 '17 at 14:28
  • ,but i want to change it programmatically , i mean in java code @Aliy – Anuj Arora Dec 31 '17 at 14:37
  • @AnujArora if this is working and you want to set it programmatically, try params.setMargins(0, 50,0, 0); – Alejandro Cumpa Jan 03 '18 at 00:47
  • @Aiapaec an Object of LayoutParams cannot be created for a sliding drawer. So i tried to create an Object of LayoutParams.ViewGroup. SlidingDrawer is a child of ViewGroup right??. And when i build it ,the terminal gives ClassCastException. – Anuj Arora Jan 06 '18 at 04:24