Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9320501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:38:58+00:00 2026-06-19T03:38:58+00:00

How to Create Slide Drawer in android app same as in facebook app.

  • 0

How to Create Slide Drawer in android app same as in facebook app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:38:59+00:00Added an answer on June 19, 2026 at 3:38 am

    Create XML Layout

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >
    <LinearLayout
        android:id="@+id/menu"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:background="#51d7ff"
        android:orientation="vertical" >
        <ListView
            android:id="@+id/ListView01"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#51d7ff"
            android:cacheColorHint="#51d7ff" >
        </ListView>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/app"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:background="#033333"
        android:orientation="vertical" >
        <Button
            android:id="@+id/BtnSlide"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/menu" />
        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#758fb1"
            android:cacheColorHint="#758fb1" >
        </ListView>
    </LinearLayout>
    

    Main Activity

    public class MainActivity extends Activity implements AnimationListener
    {
    
    Button Slide_Button;
    View menu;
    View app;
    boolean menuOut = false;
    AnimParams animParams = new AnimParams();
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        menu = findViewById(R.id.menu);
        app = findViewById(R.id.app);
    
        Slide_Button=(Button)findViewById(R.id.BtnSlide);
        Slide_Button.setOnClickListener(OnClick_slide);
    
        ListView listView = (ListView) app.findViewById(R.id.list);
        ViewUtils.initListView(this, listView, "Itemwa ", 30, android.R.layout.simple_list_item_1);
    
        ListView listView1 = (ListView) menu.findViewById(R.id.ListView01);
        ViewUtils.initListView(this, listView1, "Itemwana ", 10, android.R.layout.simple_list_item_1);
    }
    
    Button.OnClickListener OnClick_slide=new Button.OnClickListener()
    {
    
        @Override
        public void onClick(View arg0)
        {
            // TODO Auto-generated method stub
            System.out.println("onClick " + new Date());
            MainActivity me = MainActivity.this;
    
            Animation anim;
    
            int w = app.getMeasuredWidth();
            int h = app.getMeasuredHeight();
            int left = (int) (app.getMeasuredWidth() * 0.8);
    
            if (!menuOut)
            {
    
                anim = new TranslateAnimation(0, left, 0, 0);
                menu.setVisibility(View.VISIBLE);
                animParams.init(left, 0, left + w, h);
            } 
            else 
            {
    
                anim = new TranslateAnimation(0, -left, 0, 0);
                animParams.init(0, 0, w, h);
            }
    
            anim.setDuration(500);
            anim.setAnimationListener(me);
    
            anim.setFillAfter(true);
    
            app.startAnimation(anim);
        }
    
    };
    
    void layoutApp(boolean menuOut) 
    {
        app.layout(animParams.left, animParams.top, animParams.right, animParams.bottom);
    
        app.clearAnimation();
    
    }
    
    @Override
    public void onAnimationEnd(Animation animation) 
    {
        menuOut = !menuOut;
        if (!menuOut) 
        {
            menu.setVisibility(View.INVISIBLE);
        }
        layoutApp(menuOut);
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) 
    {
    
    }
    
    @Override
    public void onAnimationStart(Animation animation)
    {
    
    }
    
    
    static class AnimParams 
    {
        int left, right, top, bottom;
    
        void init(int left, int top, int right, int bottom) 
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }
    }
    

    ViewUtils.java

     public class ViewUtils
     {
     public static void setViewWidths(View view, View[] views) 
     {
        int w = view.getWidth();
        int h = view.getHeight();
        for (int i = 0; i < views.length; i++) 
        {
            View v = views[i];
            v.layout((i + 1) * w, 0, (i + 2) * w, h);
        }
     }
    
    
    public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) 
    {
        // By using setAdpater method in listview we an add string array in list.
        String[] arr = new String[numItems];
        for (int i = 0; i < arr.length; i++)
        {
            arr[i] = prefix + (i + 1);
        }
        listView.setAdapter(new ArrayAdapter<String>(context, layout, arr));
        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)
            {
    
            }
        });
        } 
     }
    

    I hope you got your answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a drawer functionality, similar to the Facebook app, with two
Possible Duplicate: Android: How to create slide (on/off) button I want to create sliding
I am trying to create the same type of slide-up/pull-up menu (from the bottom)
How can I create a Slide-Bottom-To-Top animation when close/stop an activity in android application?
I need to create a slide show of some images that can go full
I am using reStructuredText & rst2s5 to create S5 slide presentations. It is great
I'm using the very nice PhotoSlider script from http://opiefoto.com/articles/photoslider to create a slide show
Eventually I'm trying to create a timed slide show that fades images in and
I learned how to create a view controller and make the view slide in
How to create a slide view to left and right like given in Mozilla

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.