Ich habe ein lineares Layout
und ich möchte am unteren Rand eine Scheibe erstellen.
Ich weiß, dass es einige Optionen gibt, aber ich bin ein bisschen verwirrt
1) Android:layout_gravity:"bottom"
-> das funktioniert bei mir aus irgendeinem Grund nicht.
2) Android:gravity_weight="0"
und gib dem Geschwister davor Android:gravity_weight:"1"
3) Android:height="wrap_content"
und gib dem Geschwister davor Android:height:"match_parent"
Ich weiß, wie man das mit relativeLayout macht, aber ich möchte linearLayout üben
was würdest du vorschlagen?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:background="@color/blue_bg"
Android:orientation="vertical" >
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:layout_marginBottom="10dp"
Android:layout_marginTop="5dp"
Android:src="@drawable/signup_illu_why" />
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:layout_weight=""
Android:orientation="horizontal" />
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/signup_skip_icon" />
</LinearLayout>
Tatsächlich können Sie die Schwerkraft des übergeordneten Elements auf unterste Ebene setzen
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:background="@color/blue_bg"
Android:orientation="vertical"
Android:gravity="bottom" >
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:layout_marginBottom="10dp"
Android:layout_marginTop="5dp"
Android:src="@drawable/signup_illu_why" />
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:layout_weight=""
Android:orientation="horizontal" />
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/signup_skip_icon" />
</LinearLayout>
<LinearLayout
Android:orientation="vertical"
... >
<Space
Android:layout_width="match_parent"
Android:layout_height="0dp"
Android:layout_weight="1" />
<SomeViewThatNeedsGoBottom
... />
</LinearLayout>
versuche dies
<?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="match_parent"
Android:background="#ffffff"
Android:orientation="vertical" >
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/ic_launcher" />
<LinearLayout
Android:layout_width="fill_parent"
Android:layout_height="wrap_content"
Android:layout_alignParentBottom="true"
Android:orientation="vertical" >
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/ic_launcher" />
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:background="@Android:color/black"
Android:orientation="vertical"
Android:weightSum="1">
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:orientation="vertical"
Android:layout_weight="0.8" >
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/ic_launcher" />
<ImageView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:orientation="horizontal"
Android:layout_weight="0.2" />
</LinearLayout>
Benutzen:
Android: Schwerkraft = "unten"
beispiel:
<LinearLayout
Android:layout_weight="7"
Android:layout_width="0dp"
Android:layout_height="match_parent"
Android:orientation="vertical"
Android:weightSum="5">
<TextView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:text="some text"
Android:layout_weight="2"
Android:gravity="bottom"
/>
<TextView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:text="some text"
Android:layout_weight="1"/>
<TextView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:text="some text"Android:gravity="center"
Android:layout_weight="2"/>
umhüllen Sie Ihr lineares Layout mit Framelayout und geben Sie der Schwerkraft den Boden. Es ist einfacher als Sie denken ... Viele Layouts werden nur zur Erleichterung des Designs verwendet
<FrameLayout
Android:layout_height="fill_parent"
Android:layout_width = "fill_parent">
<LinearLayout`
Android:layout_height="wrap_content"
Android:layout_width = "wrap_content"
Android:layout_gravity = "bottom"
Android:orientation = "vertical">
<Button
Android:layout_height="wrap_content"
Android:layout_width = "wrap_content"
Android:text = "btn"/>
</LinearLayout>
</FrameLayout>
`