Is there a way to get the TabHost Activity to animate every time the tab is tapped? Right now i have the animation applied to the Activity that appears under the tab, but it will only every animate once (the first time it is loaded). Its a simple animation of the View coming in from left to right.
You should add onResume() method and do the same thing as the onCreate() in the activity. Then the animation should appears every time you tap it.
Related
I have an activity with the bottom navigation menu.
I want to make it when I press the middle button on the menu, a small fragment pops up (doesn't fill the whole screen) and the rest of the screen gets a little bit darker and every touch that occurs outside of the small fragment I created will not be recognized as a touch in the other background fragment but instead will destroy the small fragment.
I created the small fragment and called detach and attach to the background fragment when I create and destroy the small one. However, it doesn't call the onPause and onResume functions in the fragments so it doesn't work. Also, I don't know how to make it that if I press outside of the fragment, it gets destroyed.
Can anyone help me?
That's what I'm trying to achieve:
I have two activities one with some data and the second one, semitrasparent with some buttons on it.
I want the second activity slide over the first one after the swipe gesture.
I've already read about ViewPager and it's not what I am looking for. I want the first activity still being visible over the semitrasparent second one.
I am looking for any suggestions how to do this.
Literally not possible.
The entire point of an Activity is that it fills the ENTIRE screen, and there are never 2 of them shown at the same time, ever.
So you can't swipe to "semi" open one with a slide animation.
To do that, you'll have to use 1 Activity, and multiple Fragments.
http://1.bp.blogspot.com/-Vv4SxVSI2DY/VEqQxAf3PWI/AAAAAAAAA7c/mfq7XBrIGgo/s400/activity_transitions%2B%281%29.gif
This is a material animation I want to implement, but I can't achieve a similar effect. First of all, the shared element transition moves the image into the second activity. This is quite simple, but then the root layout of the activity starts expanding and during the animation the user can see the first activity until the second activity's view doesn't hide it totally.
I have a scenario in which from an activity, on the click of a button, I need to show a fragment with sliding in from right to left and similarly when I press back fragment slides back to the right and shows my previous activity from which the fragment was added.
Now my issue is that the animation to the fragment itself works but I need to animate the activity by sliding out to the left while the fragment is sliding in from the right.
Tried using overridePendingTransition method to do this:
overridePendingTransition(R.anim.push_in_from_left, R.anim.push_out_to_left);
I tried putting the pending transition in the methods available with the activity onResume, onPause, etc. but didn't get it to work. Following is the code I am using:
overridePendingTransition(R.anim.push_in_from_left, R.anim.push_out_to_left);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.pull_in_from_left, R.anim.push_out_to_left, R.anim.pull_in_from_left, R.anim.push_out_to_left);
transaction.add(R.id.events_holder, myFragment);
transaction.addToBackStack("myFragment");
transaction.commit();
Tried to put the pending transition on the click of the button as well, before I start doing the fragment transaction things, but didn't work either.
It would be really helpful if anybody can suggest a solution to this problem.
You aren't overriding any animation, sliding in a fragment should not move the layout of the activity if you are doing it right. Instead you have to apply an animation which you can define in an xml to the layout containing your activity. In essence you will give the appearance your activity slides out, and fragment slides in. Depending on what target you are building for, after you apply the animation you may need to actually move (in this case applying an animation doesnt actually change the physical location of the layout, it will simply render where you tell it.) the layout containing the fragment. You dont need to physically move the layout containing the activity, because if you specify an empty onclick listener for the bottom layer layout in the fragment no clicks will fall through. When you are done, use another xml animation file to slide the fragment and Activity layout back the way they were (so an opposite animation) and then physically move the fragment back out of the way, or it will still receive all of the on click events. (I do believe this issue has been fixed if you are targeting a new sdk)
an animation xml looks something like this
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
</set>
I'm building an application where i use a tabhost. In each tab there is a fragment, so the user can swipe through each fragment. I want different buttons in each fragment but them on the tabhost, so that they won't swipe too. So i change each button in the onTabChanged() method of the tabhost dynamically. But this results in slowing down, actually freezing for a bit. I even tried putting it on a thread but it didn't make any difference. Do you know any way that i can use so that the swiping through the screens will be smooth again?
Thank you for your time.
your explanation is really fuzzy but as far as I understood what you want to do is to move the buttons to outside the tabhost and on the click event you use something like:
switch(tabHost.getCurrentTab(){
// do stuff
}