Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout Gravity problem: android:layout_gravity="end"

I'm new at starting learning Android Studio and I'm having some trouble here. on this explanation of the code, I'm supposed to see the Hello world stick to the right but he doesn't wanna move from the left. Here is what is expected : result expected and what I'm having result at the moment.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:gravity="center"
        android:text="Hello World!" />

</LinearLayout>
like image 721
Frédéric Wojcikowski Avatar asked Oct 17 '25 16:10

Frédéric Wojcikowski


1 Answers

Add android:orientation="vertical" to your LinearLayout. Default orientation is horizontal.