Search code examples
androidlayoutviewdraggable

What is this Control or View?


Please see the Image

hello I want to use this type of Layout in my applicationenter image description here

If I drag one layout to any direction then i want to display other Layout

is it possible please help me


Solution

  • Try that

    Main.java:

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.ImageView;
    import android.widget.SlidingDrawer;
    import android.widget.SlidingDrawer.OnDrawerScrollListener;
    
    public class Main extends Activity {
    
        SlidingDrawer   mSlide;
        ImageView       mImageSlideHandle;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            mSlide = ((SlidingDrawer)findViewById(R.id.slide));
            mImageSlideHandle   = ((ImageView)findViewById(R.id.handle));
    
            mSlide.setOnDrawerScrollListener(new OnDrawerScrollListener(){
                @Override
                public void onScrollEnded() {
                    if (mSlide.isOpened()) {
                        mImageSlideHandle.setImageResource(R.drawable.ic_tray_expand);
                    } else {
                        mImageSlideHandle.setImageResource(R.drawable.ic_tray_collapse);
                    }
                }
    
                @Override
                public void onScrollStarted() {
    
                }
            });
    
        }
    }
    

    main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"  >
    
        <TextView  
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content" 
             android:text="@string/hello" />
    
        <SlidingDrawer 
             android:layout_height="wrap_content" 
             android:handle="@+id/handle" 
             android:content="@+id/content" 
             android:id="@+id/slide" 
             android:layout_width="fill_parent"
             android:orientation="vertical" >
    
            <ImageView 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:id="@id/handle" 
                android:src="@drawable/ic_tray_expand"
                android:background="@drawable/handle" />
    
            <LinearLayout 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:id="@id/content" 
                android:background="#FFFFFFFF"
                android:gravity="center" >
    
                <Button 
                    android:text="Button01" 
                    android:id="@+id/Button01" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" />
    
                <Button 
                    android:text="Button02" 
                    android:id="@+id/Button02" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </SlidingDrawer>
    </LinearLayout>