The basic idea is simple: Use a SlidingDrawer with an invisible handle.
In your activity add the SlidingDrawer to your content view. I usually set the Handle's height and width to 0dp. Then when you want to show the Expanded View you can just open the drawer.
To hide or show the drawer is pretty straight forward using animateOpen and animateClose of the SlidingDrawer. It is preferable to wrap these calls in your own functions in order to be able to add your own code upon closing/opening the drawer. I know that we can use the OnDrawerOpenListener and OnDrawerCloseListener: just a matter of taste. Just wrap them in your own calls:
public void showDrawer() { mDrawer.animateOpen(); } public void hideDrawer() { mDrawer.animateClose(); }
An important point to keep in mind is to handle the onBackPressed() of the activity that contains such a drawer
@Override public void onBackPressed() { if(mDrawer.isOpened()) hideDrawer(); else super.onBackPressed(); }
Click here for Sample Project + Source Code (download)
Here is the full code of the activity.
public class MainActivity extends Activity { SlidingDrawer mDrawer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDrawer = (SlidingDrawer) findViewById(R.id.drawer); findViewById(R.id.buttonshow).setOnClickListener(new OnClickListener() { public void onClick(View v) { showDrawer(); } }); findViewById(R.id.buttonhide).setOnClickListener(new OnClickListener() { public void onClick(View v) { hideDrawer(); } }); } public void showDrawer() { mDrawer.animateOpen(); } public void hideDrawer() { mDrawer.animateClose(); } @Override public void onBackPressed() { if(mDrawer.isOpened()) hideDrawer(); else super.onBackPressed(); } }
You might have a look on a library I'm working to get expandable views in Android: https://github.com/AndreasZeiser/Jalousie
ReplyDeleteI will check it out. Downloading library and sample.
DeleteI have posted a comment in the issue tracker.
DeleteObat Aborsi,, Obat Penggugur Kandungan,,
ReplyDeleteNice bag you can earn money from that
Thanks for your posting
Visit me @, Jual Obat Aborsi,,
Great Article. Thank you for sharing! Really an awesome post for every one.
DeleteAvoiding Data Corruption in Drop Computing Mobile Networks Project For CSE
EdgeCare Leveraging Edge Computing for Collaborative Data Management in Mobile Healthcare Systems Project For CSE
Energy Efficient Mobile Service Computing With Differential Spintronic C ElementsA Logic in Memory Asynchronous Computing Paradigm Project For CSE
Formal Analysis of Language Based Android Security Using Theorem Proving Approach Project For CSE
Group Wise Itinerary Planning in Temporary Mobile Social Network Project For CSE
Image Steganography Based on Foreground Object Generation by Generative Adversarial Networks in Mobile Edge Computing With Internet of Things Project For CSE
Interest Driven Outdoor Advertising Display Location Selection Using Mobile Phone Data Project For CSE
i VALS Visual Attention Localization for Mobile Service Computing Project For CSE
Engineering mathematics 1
ReplyDeleteVTU 2nd SEM syllabus
Basic Electronics Engineering Tuition Classes in Vijayanagar, Bangalore
Basic electrical engineering Tuition classes for B.tech students
Best Java Training in Bangalore
Java Training institute in Bangalore
Best Java Training institute in Bangalore
Java Training institutes in Bangalore
Best Java Training institutes in Bangalore
ReplyDeleteغسيل خزانات بمكة شركة غسيل خزانات بمكة
غسيل خزانات بجدة شركة غسيل خزانات بجدة
غسيل خزانات بالدمام شركة غسيل خزانات بالدمام
Get today replays online tambayan ofw all the replays are avaialable for you which you will be watch online in a single click.
ReplyDeleteInternet Business Ideas for 2020
ReplyDeleteBenefits Of Micro Switch and More About the China Micro Switch Company
ReplyDeletevery nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing
ReplyDeletecarboxyl
utsa blackboard
linear interpolation
antiderivative calculator
anesthesia technician course syllabus
What are the Scientific Reasons for Choosing Printed Books
favourite fruit mango
bds full form