Android 带间距的ImageView,即使包含“包裹”内容`

Android 带间距的ImageView,即使包含“包裹”内容`,android,android-layout,Android,Android Layout,有人能帮我吗?我的ImageView没有明显的原因就获得了巨大的间距。Xml: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fragment_container_3" xmlns:android="http://schemas.android.com/apk/res/

有人能帮我吗?我的ImageView没有明显的原因就获得了巨大的间距。Xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fragment_container_3"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_marginTop="50dp"
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:id="@+id/cv1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:layout_marginBottom="6dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                card_view:cardElevation="10dp"
                card_view:cardCornerRadius="4dp">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:id="@+id/img"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:layout_marginBottom="0dp"
                        android:padding="0dp"
                        android:src="@drawable/list_cli2"
                        android:contentDescription="123" />

                    <TextView
                        android:id="@+id/totalCli"
                        android:layout_width="300dp"
                        android:paddingBottom="10dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:textColor="#fff"
                        android:layout_marginTop="10dp"
                        android:text="Total de Clientes: Buscando..."
                        android:textAllCaps="false"
                        android:textAppearance="@style/TextAppearance.AppCompat.Title" />

                    <com.github.mikephil.charting.charts.PieChart
                        android:id="@+id/cliChar"
                        android:layout_width="300dp"
                        android:layout_height="200dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="21dp" />

                </RelativeLayout>

            </android.support.v7.widget.CardView>

            ...
        </RelativeLayout>

    </ScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/refresh"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="18dp"
        android:layout_marginBottom="60dp"
        android:clickable="true"
        app:backgroundTint="@android:color/background_dark"
        app:fabSize="normal"
        app:srcCompat="@drawable/refresh"/>

</FrameLayout>

如果我将android:layout_height=“”设置为一个较低的值,键入200dp,间距就会消失,但在这种情况下,在较小的设备上,视图将过时。已尝试:

  • 将图像放置为
    线性布局的背景
    ,但间距为上方和下方

  • 但是,将
    ImageView
    放在
    LinearLayout
    中,所做的操作与上述操作相同

有人知道怎么解决吗


如果我把它放在ScLoVIEW视图之外,IVIEVIEW集中在屏幕的中间

< P>将此添加到您的图像视图:

android:scaleType="centerCrop"

“缩放类型”属性将说明图像应如何适应可用空间。中心裁剪将使其填满整个空间,但作为一种折衷,图像似乎会被放大。您还可以尝试其他缩放类型。

看起来您的列表\u cli2 drawable已经有了空白。通过使用图像编辑器打开它进行检查,看看是否有空白。

现在它占据了所有的cardview,但仍然从侧面断开KKKK,没有工作我查看了链接,测试了所有选项,结果是图像都被拉伸,并且在所有情况下都占据了整个cardview。什么是“巨大的间距”你想扔掉吗?我放在问题旁边的那张图片,下面所有的白色部分你有没有试着为scrollview设置android:layout\u height=“wrap\u content”?没有,我在photoshop中占据了所有的白色/透明空间“视图将过时?”