Central alignment appears correctly in the preview of the activity, but not in the execution of the app?

0

I placed center alignment for all textView and activity preview, still in android studio, all right:

ButwhenIruntheappitdoesnothappen:

Evenifyousetthelayout_widthoftextViewstomath_parentsothattheyhidethewholeextensionofthedeviceinthehori-zontal,youdidnotgettheexpectedresult:

xlmdaactivity:

<?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>
    
asked by anonymous 20.03.2017 / 00:06

1 answer

2

Use the Next Code in your textviews

android:gravity = "center" to center horizontally and vertically on your function, if you want a specific centering as horizontal would be android:gravity="center_horizontal"

If you want more information about the subject link

    
20.03.2017 / 19:07