Mar*_*oYT 1 layout android android-recyclerview cardview
我正在使用 xamarin android 制作一个 android 应用程序,其中我使用带有回收器视图的cardview。
问题
图像高度超过文本的换行内容。
想要什么
我希望图像大小是文本覆盖的大小。
我尝试过的:
我尝试将图像设置为线性布局的背景,但它设置的布局本身的高度比下图所示的要大得多。我尝试在框架布局中设置它,但它给出与下面相同的结果
有关图像的详细信息
数字随卡视图实例一起提供
1:图像图像源高度正在增加视图高度
2:该图像设置完美,因为原始图像高度分辨率较低,并且图像被拉伸才能查看
3:图像高度分辨率再次很高,因此图像扩展了视图
4,5 卡片视图,无图像
我的代码:
<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="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cardView"
app:cardBackgroundColor="@android:color/transparent">
<ImageView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:id="@+id/cardImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/templateLayout"
>
<TextView
android:text="Title:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/listTitle"/>
<TextView
android:text="Start Time:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listSTime"/>
<TextView
android:text="End Time:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listFTime"/>
<TextView
android:text="Description:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listDescription"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
图片:
将以下字段添加到 ImageView
android:scaleType="centerCrop"
android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1323 次 |
| 最近记录: |