【发布时间】:2016-12-21 01:41:45
【问题描述】:
在屏幕截图下方,我使用ImageView 将图像插入CardView。
问题是,我似乎无法摆脱图像下方的空白区域。 (以浅蓝色突出显示)
我试过a solution that works,但它需要我明确指定图像高度,我尽量不这样做,因为来源可以是多种多样的,我需要图像灵活地放大/缩小(具有相同的纵横比) 取决于卡片宽度。
截图如下:
这里是sn-p的代码:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="7dp">
<TextView
android:id="@+id/caption_text"
android:text="Hello World!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:scaleType="fitStart"
android:layout_below="@id/caption_text"
android:src="@drawable/food"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
那么,有没有办法让CardView 自动环绕图像(不留任何空白)并且不明确指定图像高度?
【问题讨论】:
标签: android imageview cardview