Reputation: 331
I want to realize a function like that when I chick a button in a parent activity, the parent activity shove right or left like it shoved by sub activity. The opened sub activity occupy 80% screen. And the small part of the left parent activity occupy 20% screen.
How to let the parent and child activity show at the same time ?
Upvotes: 0
Views: 293
Reputation: 9182
I know exactly what you're looking for- they're called sliding drawers. Here's a great library. Here's another. I prefer feinstein's library as it has fewer bugs. Jake wharton's version is still in its early stages (Jake is a great developer- you might've used/heard of his famous actionbarsherlock library). Both libraries work on older versions of Android too, and use Fragments (hence, you need to also download android's v4 support library).
Anyway, so there are 2 ways for you to implement what you want. You can enable slide and allow the user to slide out the top view to the corner (occupying 20% of the space in your own terms). Otherwise, you can disable slide, and allow the user to click a button which will trigger the sliding behaviour.
It will end up looking like this, which, I believe, is what you want :
Upvotes: 0
Reputation: 32016
You do not want to use Activity
s, but Fragment
s for this. It is what they were designed for. See Building a Dynamic UI with Fragments to get started. The section on Building a Flexible UI shows the design you are looking for.
Upvotes: 2