Use Xamarin to realize the Park friends: Android floating ball and boot from boot

Source: Internet
Author: User

Original: Use Xamarin to realize the Park friends: Android floating ball and boot from boot

two days ago, there was a cheese in the garden. Android floating small ball with boot from start , feel this is 360 play rotten function originally is so simple ah ...

I don't have Java, and of course I don't know how to use ADT to develop Android apps.

But I've seen a few days of Xamarin, C # I still will.

With Xamarin to do Android, as long as the Java source code, I can still translate a copy out.

I installed the first time VS2015, very good, with the Android simulator, more than the third-party genymotion simulator much faster !

But Xamarin is still charged, but in town, we all know, haha.

Let me show you the result of my translation:

As usual, source code:

Https://github.com/gruan01/Xamarin-Example/tree/master/FloatBall

Xamarin declares a Service to write like this:

1 namespace Floatball {2    [Service]3     [Intentfilter (newstring " Xamarin.ballservice " })]4public     class Ballservice:service, View.iontouchlistener, View.ionclicklistener {

The latter two interfaces are not required.

Intentfilter is not a must.

To run this Service, write this in mainactivity:

1 protected Override voidOnCreate (Bundle bundle) {2             Base. OnCreate (bundle);3 ..... 4 ..... 5 6              This. Finish ();7 8             //var intent = new Intent (Application.context, typeof (Ballservice));9             varIntent =NewIntent ("Xamarin.ballservice");Ten              This. StartService (intent); One}

In the Service, if you want to get to WindowManager to write this:

1 Private iwindowmanager WindowManager {2             Get {3                 // is not a simple type conversion, be sure to use Javacast 4                 return this. Getsystemservice (Context.windowservice). Javacast<iwindowmanager>(); 5             }6         }

Note that it is not a simple forced type conversion, be sure to use Javacast

Add a child view to a WindowManager

This is a little egg-making. The Type of Layoutparameter was not set at first

Param. Type = Windowmanagertypes.phone;

Always reported this error:

Android.view.windowmanager$badtokenexception:unable to add Window-token null was not a for application

Searched a lot of pages, said basically the same, just do not apply to my scene.

Later carefully looked at the garden Friends of the article, found that less param. Type This parameter ... , plus it's OK!

Can I say it's a wonderful flower?

Framelayout & Animation

Do not understand why animation should go to the framelayout, why a little role can not afford.

Applied to the ImageView, the effect came out immediately.

I do not know whether I am wrong, or the illusion.

Finally, please ask:

, I did a shapedrawable to Framelayout.

In fact I want to show out a round picture out.

How do I do that?

Thanks for the onlookers.

Use Xamarin to realize the Park friends: Android floating ball and boot from boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.