Space is a lightweight View subclass
that may be used to create gaps between components in general purpose layouts.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FF550D"
>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Show data"
android:background="#ffffff"
/>
<Space
android:layout_width="match_parent"
android:layout_height="100dp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ok"
android:onClick="goClick"
/>
</LinearLayout>
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FF550D"
>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Show data"
android:background="#ffffff"
/>
<Space
android:layout_width="match_parent"
android:layout_height="100dp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ok"
android:onClick="goClick"
/>
</LinearLayout>
Use Space or View to add a specific
amount of space. For 30 vertical density pixels:
<Space
android:layout_width="1dp"
android:layout_height="30dp"/>
If you need a
flexible space-filler, use View between items in a LinearLayout:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
or
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_weight="1"/>
This works for most layouts for API 14 &
later, except widgets (use FrameLayout instead).
|
No comments:
Post a Comment