为什么我的卡片视图有很长的余量

时间:2016-08-09 15:44:21

标签: android xml android-layout android-cardview

简单的问题, 为什么我的Card View在其他列表之间有很长的保证金?

Long Margin

这是我的代码 的 card.xml     `          

  <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:scaleType="fitXY"
            android:id="@+id/imagePasar" />

        <TextView
            style="@style/Base.TextAppearance.AppCompat.Body1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="Material Design is stunning!!!"
            android:id="@+id/namaPasar" />

    </LinearLayout>


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

`

并且主要是mainActivity中使用的mainLayout

MainLayout

`<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="id.web.gosoft.pasarwiki.MainActivity"
  tools:showIn="@layout/app_bar_main">
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RecViewListPasar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

1 个答案:

答案 0 :(得分:0)

这是因为android:scaleType="fitXY"。这将使用Fill缩放图像。阅读this指南以获取更多帮助。