Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Adjust the size of the interfaces according to the screen

BriceFernandezBriceFernandez USMember
edited June 2013 in Xamarin.Android

Hello,

I want to know if there is a way to adapt the interfaces according to the screen.

Currently, I'm using a LinearLayout with 2 Buttons and 2 TextView, it look like this :

imageHeberger image" alt="" />

As you can see on the screenshot, i need my buttons and textviews to be center horizontal and vertical.

Currently I'm using the layout_margins to position my buttons like android:layout_<del></del>marginLeft = "110dp" for the buttons, but if the screen of the device is bigger, rendering is not the same...

For the Textviews it's ok, i use android:gravity="center_horizontal", but this property don't work for the Buttons.

Thank you by advance and sorry for my bad english

Posts

  • StevenTheEvenStevenTheEven SEMember ✭✭✭

    Have a look at this:

  • SKallSKall USMember ✭✭✭✭

    I would create a custom layout and set the controls from code, override OnSizeChanged and use SetPadding(...) to center them. In the long run creating Android layouts is much easier with code than using the XML files.

  • FZelleFZelle DEMember ✭✭✭

    No it isn't.

    Especially if you have more sizes, because then you can just use the Android system of different Layout folders for different resolutions.

Sign In or Register to comment.