android - LinearLayout 中 View 之间的意外空间

标签 android android-linearlayout spacing

我有以下布局:

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

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:id="@+id/fragment_send_imageView"
        android:layout_margin="0dp"
        android:padding="0dp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:padding="0dp"
        android:layout_margin="0dp">

        <com.google.android.gms.maps.MapView
            android:id="@+id/fragment_send_mapView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>
</LinearLayout>

在我的设备上它看起来像这样: enter image description here
如您所见,有两个“分隔线”——一个在应用程序窗口的上边框和 ImageView 之间,第二个在 ImageView 和 MapView 之间。我已将填充/边距设置为 0 - 运气不好。我该怎么办?

最佳答案

为你的 ImageView 试试这个

<ImageView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="3"
    android:id="@+id/fragment_send_imageView"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    android:padding="0dp"/>

关于android - LinearLayout 中 View 之间的意外空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22010947/

相关文章:

android - 获取Android中动态添加的LinearLayouts的高度

css - <img> 和 div 之间的虚幻间距

Flutter:多行文本小部件上的多余空间

java - 在 Google Places API 中将自动完成搜索限制为 "India"

android - 如何防止谷歌云存储重定向

android - 如果使用 android 工具来重命名包名称而不会出现任何错误/冲突

android - 增加 TextView 的 TextSize 然后减小它不会返回到 View 元素的正常高度

android - 如何解析来自 401 状态码的 json 响应?安卓

java - 如何将颜色资源作为参数传递 (Android)

html - CSS 和 HTML 表格 - 间距/填充/边框问题(不确定是哪个)