使用Android的重量定制版图 [英] custom layout using weight Android

查看:292
本文介绍了使用Android的重量定制版图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了把画面的所有空间我做了这个布局:

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>

在Eclipse中的布局似乎也不错,这是由Graphica布局给出的观点:

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

但在现实,到我的手机(三星Galaxy S3)我得到这样的:

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

而对于信息,我使用的ActionBarSherlock为主题。

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

推荐答案

尝试调整片段重量 您需要量。

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"/>

这篇关于使用Android的重量定制版图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆