Layout Probleme

V

Viperb0y

Neues Mitglied
0
Hallo,

ich habe soeben wieder mit ein wenig Android Programmierung angefangen und habe mal wieder Probleme mit den Layouts.

Habe aktuell folgendes Layout:



und der dazugehörige Code:

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <Chronometer
        android:id="@+id/chronometer1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="50dp" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="horizontal"
        android:weightSum="2" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/startbutton" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/resetbutton" />
    </LinearLayout>

</LinearLayout>

Nun möchte ich dass die beiden Buttons am unteren Rand des Bildschirms angezeigt werden. Sollten aber nicht press anliegen sondern ein wenig Abstand zum Rand.

Habe nun schon rumgebastelt und gesucht aber nichts passendes gefunden. Weiß nur dass es eigentlich ein mini Problem ist, ich aber aktuell nicht auf die Lösung komme :(.

Vielen Dank für eure Hilfe!
 
Mit "RelativeLayout" funktioniert das und mit margin definierst du einen Rand um die Buttons so dass sie nicht am Rand anliegen.

Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        
    <TextView
        android:id="@+id/main_progressservo2value"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="6dp"
        android:text="Hier könnte ein Text Stehen" />
    
    <View 
        android:id="@+id/separator"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerHorizontal="true" />
    
    <Button
        android:id="@+id/linker_btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@id/separator"
        android:layout_margin="10dp"
        android:text="Links"
        />
    
    <Button
        android:id="@+id/rechter_btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/separator"
        android:layout_margin="10dp"
        android:text="Rechts"
        />
    

</RelativeLayout>
 
Zuletzt bearbeitet:
Hallo,

vielen vielen Dank. Funktioniert jetzt so wie ich es haben wollte :).

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <Chronometer
        android:id="@+id/chronometer1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_centerVertical="true"
        android:padding="6dp"
        android:textSize="50dp" />

    <View
        android:id="@+id/separator"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerHorizontal="true" />

    <Button
        android:id="@+id/linker_btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dp"
        android:layout_toLeftOf="@id/separator"
        android:text="@string/startbutton" />

    <Button
        android:id="@+id/rechter_btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dp"
        android:layout_toRightOf="@id/separator"
        android:text="@string/resetbutton" />

</RelativeLayout>
 

Ähnliche Themen

S
Antworten
4
Aufrufe
990
Sempervivum
S
R
Antworten
3
Aufrufe
1.614
Ritartet
R
L
Antworten
4
Aufrufe
1.329
lonnie9020
L
Zurück
Oben Unten