【问题标题】:My internal linearLayout have some margin at bottom我的内部线性布局在底部有一些边距
【发布时间】:2015-08-21 07:42:56
【问题描述】:

我的内部线性布局(蓝色背景)似乎在底部有一些空白区域,不知道如何删除它。 外部线性布局也没有填充或边距,这个空白来自哪里

[![<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#E78F23">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_centerVertical="true"
                android:clickable="true"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:onClick="dashboard"
                android:src="@drawable/menu"/>

            <TextView
                android:id="@+id/ticket_reciever_header_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textSize="25sp"
                android:textColor="#ffffff"
                android:text="Mike Smith"/>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#20000000"
                android:layout_alignParentBottom="true">

            </RelativeLayout>

        </RelativeLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="35%0FF"
                android:gravity="center_vertical"
                android:layout_marginTop="55dp"
                android:layout_marginLeft="40dp"
                android:layout_marginRight="35dp"
                android:textSize="40sp"
                android:textColor="@color/background_material_dark"
                />
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginTop="10dp"
                android:layout_marginRight="10dp"
                android:src="@drawable/layer"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:orientation="horizontal"
            android:background="#91A4AB"
            android:weightSum="3">
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_weight="3"
                    android:layout_height="55dp">
                          <TextView
                              android:id="@+id/product_name"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_alignParentLeft="true"
                              android:layout_alignParentTop="true"
                              android:text="AMG 020 ladies shirt"
                              android:layout_marginTop="6dp"
                              android:layout_marginLeft="12dp"
                              android:textSize="20sp"
                              />
                                <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@id/product_name"
                                android:text="Purple heather"
                                android:layout_marginLeft="12dp"

                                android:textSize="12sp"
                                />
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:layout_centerVertical="true"
                                android:clickable="true"
                                android:paddingLeft="10dp"
                                android:paddingRight="10dp"
                                android:layout_alignParentRight="true"
                                android:src="@drawable/share_upper"/>

                </RelativeLayout>


        </LinearLayout>

        <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/qr_code"
                        android:layout_marginTop="30dp"

                        android:layout_gravity="center"
                        />

        <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="50dp"

                        android:layout_gravity="center"

                        android:background="#3E41B2"

                        >
                        <ImageButton
                            android:id="@+id/shedule"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/tecket_recieved_shedule"
                            android:layout_weight="1"
                            android:background="#00000000"/>
                        <ImageButton
                            android:id="@+id/location"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:src="@drawable/ticket_received_location"
                            android:background="#00000000"/>
                        <ImageButton
                            android:id="@+id/favourite"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/favourite"
                            android:layout_weight="1"

                            android:background="#00000000"/>
                        <ImageButton
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/share"
                            android:layout_weight="1"
                            android:background="#00000000"/>

                    </LinearLayout>



    </LinearLayout>]

1]1

【问题讨论】:

  • 在上一个线性布局中将 android:layout_height="50dp" 更改为 android:layout_height="match _parent"

标签: android xml android-linearlayout


【解决方案1】:

只需更新您最后的线性布局高度。设置 match_parent 代替 Hard-Coded 50dp

 <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:background="#3E41B2"

                    >
                    <ImageButton
                        android:id="@+id/shedule"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/tecket_recieved_shedule"
                        android:layout_weight="1"
                        android:background="#00000000"/>
                    <ImageButton
                        android:id="@+id/location"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:src="@drawable/ticket_received_location"
                        android:background="#00000000"/>
                    <ImageButton
                        android:id="@+id/favourite"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/favourite"
                        android:layout_weight="1"

                        android:background="#00000000"/>
                    <ImageButton
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/share"
                        android:layout_weight="1"
                        android:background="#00000000"/>

                </LinearLayout>

【讨论】:

    【解决方案2】:

    试试

    android:layout_height="match_parent"
    

    而不是

    android:layout_height="50dp" 
    

    在您的最后一个 LinearLayout 中。

    希望这会有所帮助!

    【讨论】:

      【解决方案3】:

      您已将布局的高度设置为固定值 (50dp)。更改它,使其占用所有可用空间更改

      android:layout_height="50dp"
      

      android:layout_height="match_parent"
      

      对于未来这样的 ui 问题,您可以在开发人员选项中启用“显示布局边界”。它将显示屏幕中每个视图的大小

      【讨论】:

        猜你喜欢
        • 2016-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多