0
I put alignment to the center for all textView and in the preview of Activity, still in android studio, all right:
But when I run the app the same doesn’t happen:
Even if you set the layout_width of the textViews as math_parent for them to hide all the extension of the device in the horinzontal, did not obtain the expected result:
xlm from Activity:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:customfontdemo="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="genesysgeneration.font2.MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="fonte padraum" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView"
android:layout_marginTop="159dp"
android:gravity="center"
android:text="********** asdasd **********" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="118dp"
android:gravity="center"
android:text="TextView\nasdlaslkdj\nasodjaosdjoa" />
</RelativeLayout>
To align them you need to use Gravity: put this in your textview
android:gravity="center"
that will center– Armando Marques Sobrinho
Where is your code?
– viana
With the instructions of @Armandomarquessobrinho I managed to solve Ack Lay, so I will put the code
– Boneco Sinforoso
opa! that’s right friend Dummy Sinforoso, but I positively answered @Thiago Leon because she is correct.
– Armando Marques Sobrinho
there is some difference between Gravity center and center_horizontal?
– Boneco Sinforoso
Symphonic doll the center_horizontal puts the content in the middle of the screen but in its position at the height ja the center it leaves the content centered in the middle of the screen and in the middle of the height
– Thiago Leon