Android Linear Layout steching
I think that's a rather simple Question but I don't get it the way I want it to. I Want do do a Linear Layout in Android with 3 areas.
The Top area should have a fixed height, fill_parent width. The second, below the first, should use all the room available, fill_parent width. The third, below the second, should have fixed height, fill_parent width.
Here is what i got:
<?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:orientation="vertical"
android:gravity="bottom"
android:background="#ff63a920">
<LinearLayout
android:id="@+开发者_高级运维id/top_bar"
android:layout_width="fill_parent"
android:layout_height="32dp"
>
</LinearLayout>
<com.google.android.maps.MapView android:id="@+id/mymapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
/>
<LinearLayout
android:id="@+id/bottombar"
android:layout_width="fill_parent"
android:layout_height="32dp"
>
</LinearLayout>
</LinearLayout>
The Problem is, that the mapview in the middle ist too big, so it pushes out the topbar.
I Hope you can help me.
Thanks to Sebastian that's what made the trick:
<?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:orientation="vertical"
android:gravity="bottom"
android:background="#ff63a920">
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
<com.google.android.maps.MapView android:id="@+id/mymapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/bottombar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
</LinearLayout>
there is a software called DroidDraw. (freeware) use it and it will generate the XML code autmatically for u.
Hope that helps
精彩评论