Placing Fragment Above ActionBar - android

I have a Parent FragmentActivity with a main view where I do FragmentTransactions and periodically switch views. But one particular view (a Fragment) is animated and slide in from right side of screen. I would like the view to be above (or on top of) the ActionBar.
The best example is taken from the app WunderList. Here is a screenshot.
Their app ALSO slides in and animates and this is exact functionality I am trying to duplicate. Can you do this with a Fragment? Or is this probably a new Activity?

You can't put fragment over ActionBar, but you can play with hide/show ActionBar.
On your new Fragment (on method onCrate) call:
your_activity.getSupportActionBar().setShowHideAnimationEnabled(false);
your_activity.getSupportActionBar().hide();
Then, when you want to came back to your previous screen, show ActionBar, call on method onPause:
your_activity.getSupportActionBar().setShowHideAnimationEnabled(false);
your_activity.getSupportActionBar().show();

You can do it the way you want (with or without Fragments). As answered in the other post, we've released a library that makes the sliding layer work for you (just drop it in your xml as a normal container and put whatever you need inside).
That said, the remaining issue is more related to the ActionBar being at the top or bottom layer and that has more to do with the place that it takes in your app. In the end you'll have to play around with the indices of your views and the ActionBar within their container.
For instance we did our own ActionBar which made it easier to play around and decide who goes on top and underneath, but as said it shouldn't be too much of a big deal even with the native one or Sherlock ones.
Can you post a picture of what you want to achieve?

I was able to Achieve the above effect using Fragments. Use :
fragmentTransaction.add(android.R.id.content, fragment_instance);
where android.R.id.content is always the root element of a View since api level 1 .

Related

android ui design for an app help needed

One activity in my app looks like below picture. In the below picture ,can any one suggest that best way to implement view,
view in my app
and when i click one of the options(filters in app) available on activity,
the view will be extended like below
view after one of the option selected
For this, i want to use a horizontal linear layout for below options bar,
when one of the options clicked, i wanna use slide up functionality and views show and hide functionalities.
can any one suggest better design for this . thanks.
I think for most apps, all toolbars should stay in the same place throughout the execution of the app. When the toolbar item ("Veg & Non Veg") is clicked, the filter should appear above the toolbar instead of below it. You can still use the slide up function, just have the toolbar layout displayed above (higher z-index) the filter linear layout.
You should also standardize the sizes for the distances/times to each location, personally I think the first one looks better.
Other than that, I think your UI looks pretty good!

Android implement left to right swipe animation

In android, i want to move from current to previous activity by left to right swipe as in iOS. I want to be able to even hold while swiping such as both activities are visible at the same time.
I want to introduce transition/animation effect just like in Telegram app. So please help how can i do it.
Tutorials or example code will work for me.
Thanks in advance!
You better use the Swipe animation with multiple Fragments inside one Activity: Creating Swipe Views with Tabs
take a look at this tutorial : HOW TO IMPLEMENT HORIZONTAL VIEW SWIPING WITH TABS
If you're already using Google's NavComponent library, you should try a library that I wrote:
https://github.com/massivemadness/Fragula
It's fully integrated with NavComponent, which means the navigation API stays the same, you only need to make some changes in NavGraph and NavHost container.
Here's the result:

Ideas for android navigation bar (below action bar)

I have a design for an app that will have a row of buttons below the action bar. Each button will open a different fragment. I am aware of ViewPagers, but I do not want the swipe between fragments functionality. I know that I can disable this functionality, but at that point is it worth using a ViewPager? I know this is a pretty common design paradigm, so how do most apps handle this sort of thing?
It seems like the ViewPager will provide some nice functionality out of the box, like switching between fragments and what not. So, I am leaning towards using one, but was hoping someone could provide some feedback on this approach.
Thanks!
Keep the buttons in the layout of your main activity. Have them call a function lets say loadFragment(Button button) on click.
This function then handles switching of the fragments, and you can change the display of the navigation buttons inside this function itself to highlight the appropriate button or something equivalent.
Google Design is always worth the reading.
Check http://developer.android.com/design/patterns/swipe-views.html for details.
Personally I have used ViewPager with tab layout for swiping purpose and it makes it easy to me to synchronise the transitions ( tabs and pages) where I put a red circle to the tab corresponding to the viewed page. With this approach I got a clean separated code.

Overlay a view in every activity

In an app I am working on, I'd like to have a bar with some controls always present at the bottom of the screen. It should overlay every activity in the app but also be able to disappear and reappear. To do this I've considered some options, such as simply using a linear layout and setting the visibility in every activity or using a fragment somehow. Probably those would work but I feel there must be a better solution. So my question is: what is the best way of doing this?
There are two ways you could do this. You could just use Fragments, and make your overlay be a fragment.
The other way would be to sublcass Activity with an AcitivityWithOverlay, which handles the overlay appearing and disappearing then have all of your activities inherit that. If I did it this way, I'd make my overlay a singleton so I wasn't creating extra versions all over the place that did the same thing.

How to open an activity which only occupied two-thirds screen? And the rest of the screen display the parent activity

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 ?
You do not want to use Activitys, but Fragments 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.
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 :

Categories

Resources