Android 在FrameLayout内对齐文本视图

Android 在FrameLayout内对齐文本视图,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我正在开发一款带有导航抽屉的Android应用程序。我正在我的HomeFragment.xml中使用FrameLayout。在框架布局中,我想使用3个文本视图,并希望将其垂直和水平对齐,以便对齐适用于所有屏幕尺寸。有人能帮忙吗 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:

我正在开发一款带有导航抽屉的Android应用程序。我正在我的
HomeFragment.xml
中使用FrameLayout。在框架布局中,我想使用3个文本视图,并希望将其垂直和水平对齐,以便对齐适用于所有屏幕尺寸。有人能帮忙吗

<FrameLayout 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"
   tools:context="com.example.mgdetector.HomeFragment">


<TextView
    android:text="TextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/absolute_strength"
    android:layout_marginTop="50dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:textStyle="bold"
    android:textSize="@dimen/textsize"
    />

<TextView
    android:text=""
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/current_location_latitude"
    android:layout_marginTop="150dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:textStyle="bold"
    android:textSize="@dimen/textsize"
    />

<TextView
    android:text=""
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/current_location_longitude"
    android:layout_marginTop="250dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"

    android:textStyle="bold"
    android:textSize="@dimen/textsize"
    />
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:id="@+id/stopButton"
    android:text="WARNING"
    android:visibility="gone"
    />
但我不确定这是否适用于不同手机的屏幕大小。

您应该查看此链接和此链接

android:layout_marginTop="250dp"  // with a difference of 100dp for TextView
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"