机器人列表视图与图像项目来调整图像高度proportionaly
问题描述:
我有与此图像项目的列表视图:机器人列表视图与图像项目来调整图像高度proportionaly
<?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"
android:id="@+id/llItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:layoutDirection="rtl"
android:orientation="horizontal">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="@color/white"
app:cardElevation="4dp"
app:cardUseCompatPadding="true">
<ImageView
android:id="@+id/pollimg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</android.support.v7.widget.CardView>
我需要在getview方法的图像视图加载到阵列适配器如下:
@Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
....
etc
.....
try {
Picasso.with(context)
.load(allpolls.get(position).getMediaUrl()).fit()
.placeholder(R.mipmap.icon).into(holder.img);
} catch (Exception e) {
holder.img.setVisibility(View.GONE);
}
}
我的问题是,所有行的imageview高度是固定的,我需要将imageview高度设置为与在线图像相同的图像高度。所以它可以采取它的确切高度
答
从this教程
拟合()是测量目标的ImageView的尺寸和内部使用调整大小()来将图像尺寸减小到的ImageView的尺寸。关于fit()有两件事要知道。首先,调用fit()可以延迟图像请求,因为毕加索需要等待ImageView的大小才能被测量。其次,您只能将fit()与ImageView用作目标。
这意思,如果您使用fit()
图像将被调整大小。去掉它。
如需进一步信息,如果你想保持图像的原始宽高比,你应该考虑把高度和宽度wrap_content
发表您的完整布局...代码 – rafsanahmad007
问题是更新PLZ检查 – Amalo