I am still kinda new in android development and I can not figure out how can I get smooth transition when switching between activities. I currently have this
You can try these two option.
In the intent you use to switch to another activity add this flag
Intent.FLAG_ACTIVITY_NO_ANIMATION
and in the style asset of this activity (found trough the manifest)
add this line
<item name="android:windowAnimationStyle">#null</item>
Nothing worked for me. I had to change type of animation to get rid of weird flash.
Related
I am quite new to android and java, and I would like to have a bit of help from you to figure things out.
I have been working on a live wallpaper app lately, here is what I achieved and my blocking points:
I use the WallpaperService to create my custom LWP, I change its colors and shapes based on the user preference (preference fragment screen) with preferenceChangeListener.
My main activity just handles the preference fragments and UI. Is is my main menu where I can set the WP and change the preferences.
Here is my problem: I would like to show the live wallpaper preview as background of my main activity.
I haven't figured out a way to do this so far.
The only solution I found is to show the wallpaper through the activity by changing my Theme to a transparent one.
But this requires to set the wallpaper first. Once the WP is set, my app works exactly the way I want. But before that, my main activity can't show the WP preview because the service isn't running yet.
I don't think that there's a way to extract the WP preview from the WP service. I need to change something.
Also, I don't want to show only a sample img of the WP, I really want to run my code and show the results to the user as a preview.
Could you tell me how to change my code in order to get the correct behavior? I might have to use another class that I could run in parallel or something. It is a bit obscure to me...
Thank you very much!
I am trying to show the title bar of my android app on some layouts but not on others. I navigate between layouts without a problem and I call getSupportActionBar().hide(); or getSupportActionBar().show(); without problems, the titlebar does indeed show or hide when I want it to. However, there is an animation which is very ugly and annoying plus it causes some strange graphics problems (black background in my app but it shows a white background in the place of the title bar during its animation)
There is a method for disabling the animation but it does not seem to work at all. How can I have a title bar one one activity but not the other without having an annoying animation to show/hide it? And why cant I just call the method and have it work as it should?
The method I am trying to call is getSupportActionBar().setShowHideAnimationEnabled(false);
it is worth noting that my app is extremely simple and only has two layouts and one java activity. I just inflate two different layouts to show on my one activity.
How it looks like currently: https://i.imgur.com/djTWokI.mp4
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
You can try changing AndroidManifest.xml like this
I sort of solved it myself by creating a custom titlebar which I have full control over. What really frustrated me was that setShowHideAnimationEnabled(boolean) doesnt seem to work properly and I couldnt find any official documentation about it.
Googling for it only gave me results from like 2010 about how to enable animations but when animations are enabled by default, I wanted to remove them.
Anyway, turning the actionbar off in the entire application/activity is possible and that is what I did, I then created my own custom actionbar layout and added it to the page(s) that I want to utilize it.
If your context is an activity you can call overridePendingTransition:
Call immediately after one of the flavors of startActivity(Intent) or
finish specifying an explicit transition animation to perform next.
So, programmatically:
startActivity(new Intent(CurrentActivity.this, YourNextActivity.class));
overridePendingTransition(0, 0);
I've one major issue. I built one chat app from scratch using Firebase, Java and Android, which contains many activities and class. Now suddenly I found that I forgot to set UI for Landscape mode (which is like default tablet mode). I opened my app and rotate to landscape, and UI looks very bad, even some part is not visible. I'm actually planning to publish on play store just for learning purpose. So is there any easy way to do this?
Should I restrict, so that user not able to rotate the screen for every activity like below is mation in either java or xml through?
In XML:
<activity android:name=".SomeActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
In Java:
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I also don't know that how can I do this for all activity? Should I have to crate duplicate activities for all activity? and how can I do this? where can I attach? I really don't have any idea about this. Please help me.
Studio generates layout for you just adjust the generated layout as per need and that layout will be used automatically
Should I restrict, so that user not able to rotate the screen for
every activity like below is mation in either java or xml through?
You shouldn't restrict user to one orientation, If design specs of you layout is ideal for landscape then go for it
I also don't know that how can I do this for all activity? Should I
have to crate duplicate activities for all activity? and how can I do
this? where can I attach? I really don't have any idea about this.
Please help me.
With manifest solution, yes, you have to do this for every activity entry in manifest file.
either do it via manifest or via xml.
To set orientation of all activities, you can create a base activity and extend all activities from it where your base activity set the orientation. e.g
// no need to set orientation in manifest
class BaseActivity extends AppCompactActivity{
oncreate(...){
super.oncreate(..);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
class YourOtherActivities extends BaseActivity{
oncreate(...){
super.oncreate(..);
setContentView(..);
}
}
i am working on a project and i happen to implement the "NavigationView" from the Google's Design Compat Library. But i ran into this problem where when an item is touched: i want it to change the activity.
So, what i am implying here is that can anyone give me the best solution of how i can implement this the right way like it is seen in the GMAIL app, where only the toolbar's title and the items in the List also changes.
I tried:
switch(menuItem.getitemId()){
menuItem.setChecked(true);
case R.id.navigation_item_1:
startActivity(new Intent(MainActivity.this, Feeds.class));
But the result isn't what i wanted, Please can you help me.
The comportement you describe (i.e. keeping the actionbar and other stuff), take advantage of fragments and not activities : each time an action is clicked, the displayed fragment is changed, but the activity is still the same one.
I am sure this is a basic question, but I'm developing an Android app using ADK and Eclipse.
When I try to transition Activities, the screen goes black and then briefly shows the previous activity screen before "flipping" to the new screen.
I don't have any custom transitions; I'm using the default.
I don't have much going on in my onCreate event (EXCEPT: I load my background image during onCreate! Could it be this?)
I really am looking at a very snappy transition, like a game like Words with Friends, where it appears to switch "instantly".
This depends on what phone you're using since different phones use different anamations. Try to call finish(); on every activity but your main one for example.. Or finish them all when the user switches activities