I am trying to give simple animation effect to dialog. Here I set animation theme to dialog for how it enters and how it exits. This code works properly on unlocked device but on locked device when that dialog comes and I clicked on cancel button, dialog disappear and locked screen is displayed but when i try to unlock screen immediately after clicking button then I see the dialog exits with that animation effect. But this effects goes to background and I want to show that animation effect on locked screen. The same code works on tablet but when i tried to do it on mobile it gives me this abnormal behavior.
this is zoom_out_exit.xml file.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/decelerate_interpolator"
android:zAdjustment="top" >
<translate
android:duration="5000"
android:fromYDelta="0%p"
android:toYDelta="50%p" />
</set>
this is style.xml file
<style name="AnimationTheme" parent="#android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowAnimationStyle">#style/DialogAnimation</item>
</style>
<style name="DialogAnimation" >
<item name="android:windowEnterAnimation">#anim/zoom_in_enter</item>
<item name="android:windowExitAnimation">#anim/zoom_out_exit</item>
</style>
and this theme of animationtheme is set to dialog.
class MyDialog extends Dialog {
MyDialog(Context context) {
super(context, R.style.AnimationTheme);
}
}
can anybody solve my problem ? thanks in advance.
Related
I'm looking for hints, an example or anything that could guide me with how to make a start up splash screen for Xamarin application Xamarin.Forms application.
I assume I need to make different changes to the iOS and the Android projects and have researched what I can find already.
However much of the information seems dated or no longer works.
Would appreciate any suggestions and advice on how to do this for iOS and Android.
Xamarin.Forms is a solution that, in itself, takes a while to load. Since all cross-platform things have to wait for Xamarin, there is no cross-platform good implementation of a splash screen.
It looks like you'll have to implement it separately for iOS and Android. This will enable the splash screen to show up much faster and before the standard blue Xamarin screen.
EDIT: Alan asked for a complete solution, so here it is:
iOS: Make changes to the LaunchScreen.storyboard file in the Resources section of the .iOS project (that's the splash screen, by the way). I'd suggest opening it in Xcode instead because the storyboard editor of Xcode is frankly just better than Xamarin.
Android: You're going to have to have an image here. From official Xamarin support-
The quickest way to render and display the splash screen is to create a custom theme and apply it to an Activity that exhibits the splash screen. When the Activity is rendered, it loads the theme and applies the drawable resource (referenced by the theme) to the background of the activity. This approach avoids the need for creating a layout file.
The splash screen is implemented as an Activity that displays the branded drawable, performs any initializations, and starts up any tasks. Once the app has bootstrapped, the splash screen Activity starts the main Activity and removes itself from the application back stack.
Here's the specific code involved for that. Below is for a drawable. Place it in the Resources/Drawable folder of the Android project.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash_background"/>
</item>
<item>
<bitmap
android:src="#drawable/splash"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
This is for a theme (add it to values/styles.xml, or add values/styles.xml if the document doesn't exist.).
<resources>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light">
</style>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Add this code to your Android project as MyTheme.cs:
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(SplashActivity).Name;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
Log.Debug(TAG, "SplashActivity.OnCreate");
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() => { SimulateStartup(); });
startupWork.Start();
}
// Simulates background work that happens behind the splash screen
async void SimulateStartup ()
{
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
await Task.Delay (8000); // Simulate a bit of startup work.
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
StartActivity(new Intent(Application.Context, typeof (MainActivity)));
}
}
Then, after you've done all that for Android, remove the MainLauncher attribute from MainActivity, since your launcher is now MyTheme.
This is by no means easy, but it's the only way there is right now.
Make sure you do not have SimulateStartup sample code. It used to be boiler plate code a while ago:
class SplashActivity:
It forces an await when the app starts up incase you want to make any service calls on the splash screen
MainActivity.cs
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() => { SimulateStartup(); });
startupWork.Start();
}
// Simulates background work that happens behind the splash screen
async void SimulateStartup ()
{
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
await Task.Delay (8000); // Simulate a bit of startup work.
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
StartActivity(new Intent(Application.Context, typeof (MainActivity)));
}
Other alternative to improve splash speed:
use small or native components to create your splash screen
make sure nothing is on OnResume and not calling any services
I want to set a navigation bar background image, but so far, no methods worked.
I don't know if I have to override the navigation-page renderer or if I have to change the "styles.xml", or if I have to override the Android "Toolbar", I have tried everything and I can't seem to find the solution.
I am using Xamarin Forms and Master Detail Page navigation.
I already tried changing styles.xml, making a custom toolbar layout, but doesn't mean I have done it right.
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
I have refered here. But I just see a black background.
Then I use a Android standard Theme "ThemeTranslucentNoTitleBar". It is still a black background. So how to make a activity completely transparent?
protected override void OnCreate(Bundle bundle)
{
SetTheme(Android.Resource.Style.ThemeTranslucentNoTitleBar);
base.OnCreate(bundle);
SetContentView(Resource.Layout.xxx);
}
After trying lots of times. I find the resolution. You also have to set Android application theme. For exmaple <application android:theme="#android:style/Theme.Translucent" /> If you are using a custom application theme. Do not forget to set android:windowIsTranslucent = true
<style name="CustomTheme"
parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/CustomActionBar</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<item name="android:windowIsTranslucent">true</item>
</style>
I am creating a Android Wear app that has an touch area. The user is suppose to be able to move it's finger in all directions over the screen (Think touchpad on your laptop). However the back swipe makes this a bit problematic. Any help with getting around this issue would be a great help.
How to disable the android wear back swipe?
/Jakob
There is an attribute in window style to disable this behavior:
<style name="AppTheme" parent="#android:style/Theme.DeviceDefault.Light">
<item name="android:windowSwipeToDismiss">false</item>
</style>
Once you disable it you have to provide other way of exiting your app.
There is a DismissOverlayView class (listed here https://developer.android.com/training/wearables/apps/layouts.html#UiLibrary) that you should use instead.
Basically it provides an overlay that will show a red button with cross after a long press. Clicking the red button will exit your app.
Here is a video from Google I/O 2014 with some bookmarked moments:
https://www.youtube.com/watch?v=sha_w3_5c2c#t=1390 <- disabling android:windowSwipeToDismiss
https://www.youtube.com/watch?v=sha_w3_5c2c#t=1505 <- Java code for DismissOverlayView
You can also check another video called:
Fullscreen apps for Android Wear:
https://www.youtube.com/watch?v=naf_WbtFAlY
You can try to write AndroidManifest.xml theme
android:theme="#style/Theme.Wearable.Modal inside activity tag
<activity
android:name="com.smart.remote.wear.MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.Wearable.Modal">
If you want the whole app to override Swipe, place the theme property under your Manifest's <application> tag. If you want it to apply only to a certain activity, then place the property under that activity's <activity> tag.
So:
create or update styles.xml in the res/values folder with the android:windowSwipeToDismiss property, such as:
...
false
If you want to override swipe in the whole app, Update your Manifest as such:
<application
...
android:theme="#style/AppTheme">
If you want to override swipe in a specific activity, Update your Manifest as such:
<activity
...
android:theme="#style/AppTheme">
</activity>
where ... represents all your other settings you already have. Remember you will need to give alternative ways out of the activity and/or app depending on which level you overrode
In my Android application I create such menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/rymcium"
android:title="rymcium"
android:icon="#android:drawable/ic_delete"
/>
</menu>
When I run it on old Android version (on emulated Android 1.6), icon is visible. When I run it on new Android version (on real or emulated Android 4), the icon is invisible. Is it normal? Can I do something to make it visible?
It was because my activity used theme android:Theme.Light (it was default when I created my project in eclipse). When I changed theme for android:style/Holo.ButtonBar, icons are visible.