【发布时间】:2017-05-04 14:54:34
【问题描述】:
我正在尝试将
ImageView添加到我的CardView但我不知道如何 在ImageView内设置具有全宽的图像 (match_parent) 和wrap_content高度!默认情况下会有 是 Imageview 中的一些空间(底部和顶部,取决于宽度和 图片的高度)如下所示:
有什么方法可以在不裁剪图像的情况下删除这些空白空间?
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardElevation="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/cardviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ryan_gosling"
/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
【问题讨论】:
标签: java android xml imageview instagram