How to keep a Android app in landscape - performance

I want to know if there was good way to keep my application from rotating, but let it go switch from landscape to landscape reversed?
I've only found this:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
How can I restrict my applications to those two states?

Don't wanna say it but RTM !
Here, in your Manifest add this to your activity you wanna let rotate :
android:screenOrientation="sensorLandscape"

Try adding this to your <activity> tag in the AndroidManifest.xml
android:screenOrientation="sensorLandscape"
Or if you want to do it programmatically you can add this to your activity
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}

have a look here (duplicate)
Force an Android activity to always use landscape mode
You have to define this in the manifest

You just need to do one thing, just put android:screenOrientation="landscape" in every <activity> tag of your manifest file

Just add the following line to activities added in Manifests
<activity android:name=".youractivityName" android:screenOrientation="portrait" />

Related

How to set Safe Area layout in iPhone x

I am developing Xamarin forms app and my app seems with safe area set in top. But need to ignore it.
Current scenario:
Excepted scenario:
I have googled regarding this and got below link, tried out as mentioned in below links and nothing worked.
https://forums.xamarin.com/discussion/104945/iphone-x-and-safe-margins-with-xamarin-forms
https://blog.xamarin.com/making-ios-11-even-easier-xamarin-forms/
But didn’t know how to access SetPrefersLargeTitles under Xamarin forms content page in below line mentioned in above link.
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetPrefersLargeTitles(true);
After set safe area as true output come as below,
Please help me to resolve this.
Regards,
Cheran
You can do it from XAML like this
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
Please Refer to Making iOS 11 Even Easier with Xamarin.Forms
We use Platform-Specifics to implement it.
Before iOS 11
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
iOS 11 or newer
var safeInsets = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();
safeInsets.Left = 24;
this.Padding = safeInsets;
It's necessary to create or configure LaunchScreend.storyboard.
Use this code, change splash_screen for your image.
Go to top constraint and make second Item constraint superview.Top
public ItemsPage() {
InitializeComponent();
On<Xamarin.Forms.PlatformConfiguration.iOS> ().SetUseSafeArea(true);
}

How to customize Xamarin.Forms app?

How can I customize the appearence of xamarin.forms components?
I want each button to have the same image, for instance. Or for all systems to share the same login screen with the same background image.
I know I can do that by adding one specific screen to each platform project. But I want to be able to customize the component itself. Example: All buttons will have the same background image no matter which platform is running.
I've read these:
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/styles/
http://code.tutsplus.com/tutorials/getting-started-with-xamarinforms-customizing-user-interface--cms-22144
The most promising one seems to be the last one. Is a custom renderer the only way to accomplish this? Can't I just add an image at the shared project and it automagicaly works for all platforms?
Thanks.
It's not absolutely clear, what exactly you want to reach... but I try to answer you.
If you use a shared project (based on template "Blank App (Xamarin.Forms shared)", you can use the same page / page-definition in all of your platforms.
You can add - e.g. a login-form in the shared-folder and then call it from code (e.g. from another page in the shared folder).
If you want to create your own controls, you can create "user-controls" and use it everywhere you want (what I recommend to every user).
You do this, by create a own class (e.g. with an Entry and a Label), implement the events and then instantiate it where you want to use it. E.G.
var OeFirma = new EntryErfassung(cDefaultText: "Firma", iMaximalLaenge: 45);
where OeFirma is the name of the object-instance on the page (to access it), EntryErfassung is my own class (that contains a description-label, an Entry an error-label and more) and cDefaultText is a parameter, that overtakes and set the default-text to the Entry and iMaximalaenge is a further parameter that is overtaken whereby my class then take care, that not more then 45 Characters are accepted for this Entry).
I have e.g. created a class with a description-label, a delete-button, an Entry and a error-label ad use it on all data-entry-forms.
If you want to change the look-and-feel of a specific control for a specific platform, you can create a "custom-render" (I have done this e.g. to change the font-size to the edit specific for iOS, as the font-sinze cannot be set in the XF-Entry control).
Hope this answers your question...
To do this, you can just specific a style in the App class, (you will need to change the app class to be made up of 2 partials: App.xaml & App.xaml.cs, and then create a ResourceDictionary to hold your customisations.
<Style TargetType="Button">
<Setter Property="Image" Value="MyImage.png"/>
</Style>
Hope that helps.
Cheers,
Tristan

onApplyWindowInsets is not called in CanvasWatchFaceService.Engine

I am developing a watch face using CanvasWatchFaceService.Engine
I need to detect if watch is round or square.
I overrided onApplyWindowInsets, but it is not called.
Shall I set a specific listener or something like that?
In my experience, onApplywindowInsets only gets called when you're using Theme.DeviceDefault, or a theme descending from it. It won't get called if you're using a completely custom theme.
So in the manifest for your watch face, your application tag needs to look something like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault" >
Or if you have a theme for the watch face service, that will override it.
In my experience, onApplyWindowInsets is not called unless android:
isScrollContainer = "true"
is set to any view in layout.

Tile Icon Windows Desktop App using MSDN help is not working

I am trying to create a tile icon for the windows 8.1 using the guide provided by Microsoft here. I have done everything they are asking me to do there but I am still not seeing the Tile Icon. Has this worked for anyone? can someone please help? It is picking my brain and can't sleep!!! Please help!
http://msdn.microsoft.com/en-us/library/windows/apps/dn393983.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/jj673981
<Application xmlns:xsi="w3.org/2001/XMLSchema-instance">;
<VisualElements BackgroundColor="#FFFFFF" ShowNameOnSquare150x150Logo="off" ForegroundText="light" Square150x150Logo="Assets\150x150Logo.png"/>
</Application>
Your visual manifest only specifies a 150x150 image. You need to specify both:
Important If you opt for a custom image, you must specify an image
for both the Square150x150Logo and Square70x70Logo attributes. If you
specify only one of those attributes, this entire XML file is ignored
and the default styling (app icon and background) is applied to the
tile.
I created a sample and specified both images, and it works fine for me.
Also, don't forget to refresh the shortcut:
Step 7: Important! Refresh your shortcut file
If your app is already installed, you must nudge your shortcut after
the new or updated .VisualElementsManifest.xml is in place or it will
be ignored.

Difficulty with tile background for a windows phone 7 app

I am trying to set a background for my app's tile using these instructions. However, it still shows the default spiky circle image. (I think it's "ApplicationIcon.png".)
Here is my WMAppManifest.xml:
<Tokens>
<PrimaryToken TokenID="MyAppToken" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">s.png</BackgroundImageURI>
<Count>0</Count>
<Title>My App Title</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
What could I be doing wrong? s.png is set to build action "Content".
There are two icon files. They default to ApplicationIcon.png and Background.png
ApplicationIcon is 62x62, can't be transparent and is used it the list view of applications.
Background, which is what you are setting here should be 173x173, can be transparent, and it used when you pin the application to the start screen.
So my first suggestion would be to check you are actually setting the image you think you are and are looking at the start screen not the list view.
My second would be to check the image sizes are correct. I do not know what the phone does if they are not.
My third would be to check the image you are referencing is in the top level of the project, not in a folder, and is actually making it into your xap. Go into the bin\debug or bin\release then open the .xap file with a zip client and make sure it is there.
Sometimes WP7 seems to cache the old image - so my advice would be:
if you are using the phone, then remove your app (using press and hold to bring up the menu)
if you are using the emulator, then reboot it to ensure the app is completely removed

Resources