0

In order to take all space of the screen I made this layout:

<?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:orientation="vertical"
    android:weightSum="2" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/tv_detail_placename"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical|center_horizontal"
            android:text="zeudhzeid" />

        <TextView
            android:id="@+id/tv_detail_description"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical|center_horizontal"
            android:text="Descr d zedezdezdzedez dez dezd" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical" >

        <!-- Map -->

        <fragment
            android:id="@+id/map_detail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            class="com.google.android.gms.maps.SupportMapFragment"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

In Eclipse the layout seems to be good and this is the view given by Graphica Layout:

But in real, into my phone (Samsung Galaxy S3) I got this:

And for info, I'm using ActionBarSherlock for theme.

double-beep
  • 5,031
  • 17
  • 33
  • 41
eento
  • 761
  • 4
  • 20
  • 53

4 Answers4

1
 <fragment    
            android:id="@+id/map_detail"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="2"
            class="com.google.android.gms.maps.SupportMapFragment" />

I hope this will solve it.

B3738
  • 51
  • 1
  • 1
  • 10
0

You declare new ScrollBar in xml and everthing is in it. Maps default measured dimension bigger than priview. Similarly;

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="match_parent">    

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="2" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/tv_detail_placename"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical|center_horizontal"
            android:text="zeudhzeid" />

        <TextView
            android:id="@+id/tv_detail_description"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical|center_horizontal"
            android:text="Descr d zedezdezdzedez dez dezd" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical" >

        <!-- Map -->

        <fragment
            android:id="@+id/map_detail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            class="com.google.android.gms.maps.SupportMapFragment"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="Do" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
</ScrollView>
nurisezgin
  • 1,530
  • 12
  • 19
0

try adjusting weight of Fragment by your requirment.

 <fragment
        android:id="@+id/map_detail"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="2"
        class="com.google.android.gms.maps.SupportMapFragment"/>
mrsus
  • 5,446
  • 4
  • 31
  • 44
  • It works yes! But now my map is too short.. Do you have a solution to keep this weight system but just decrease the value of buttons ? – eento Oct 10 '13 at 13:45
0

Remember to set height or width to 0dp when using weight. Maybe this is the problem.
For example you should replace this

            <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Do" />


with this

            <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Do" />

Also you should know that nested weights are not good for performance. You should reconsider your layout.

Egis
  • 5,081
  • 5
  • 39
  • 61