WhatsNext2020
WhatsNext2020

Reputation: 13

Android Studio displays layout different than physical device - LinearLayout

I'm learning Android development (a beginner). I've tried displaying a simple "Hello World!" TextView as part of a LinearLayout on Android Studio, and then on my (physical) mobile device, and got two different results. I'd like to know what is the reason for the difference.

This is the code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />

</LinearLayout>

These are the screenshots:

Android Studio Screenshot

Device Screenshot

I should point out that my mobile device is a Moto G First Generation, and the default language is Hebrew (a Right To Left language).

I should also mention that I've tried different Views combinations, and each time on Android Studio they are positioned by default on the left, while on my device - on the right.

What should I do in order for the layout to be identical in the software and in the device, as I'd like to keep using this device to write applications?

Any advice will be highly appreciated.

Thanks in advance

Upvotes: 1

Views: 81

Answers (2)

miguelarc
miguelarc

Reputation: 800

You can follow one of two ways:

If you want to keep everything RTL (Right to Left), you can change the preview in your Android Studio for a RTL locale, as it is shown here.

If you want to change it to LTR (Left to Right), you can change the language in your phone to a LTR language (en-US for example) and it will change to LTR mode.

Upvotes: 1

asozcan
asozcan

Reputation: 1390

As you see, there's a setting in editor for what you need. Good luck!

enter image description here

Upvotes: 1

Related Questions