【问题标题】:Why My Card View have very long margin为什么我的卡片视图有很长的保证金
【发布时间】:2016-12-15 18:15:49
【问题描述】:

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

这是我的代码 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

主布局

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

【问题讨论】:

  • 您的布局中的某些标签丢失。你能包括那些吗?

标签: android xml android-layout android-cardview


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-17
    • 1970-01-01
    • 2023-03-18
    • 2022-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多