2016-12-23 3 views
0

Ich arbeite an einer Android App mit Navigationsschublade. Ich verwende FrameLayout in meinem HomeFragment.xml. Innerhalb des Rahmenlayouts möchte ich 3 Textansichten verwenden und möchte diese vertikal und horizontal ausrichten, so dass die Ausrichtung für alle Bildschirmgrößen funktioniert. Kann jemand damit helfen?TextViews in FrameLayout ausrichten

<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" 
    /> 

Derzeit verwende ich

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

aber ich bin nicht sicher, ob dies sollte für Bildschirmgrößen von verschiedenen Handys arbeiten.

Antwort