【发布时间】:2017-09-06 17:10:18
【问题描述】:
我有一个包含此图像项的列表视图:
<?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);
}
}
我的问题是所有行的图像视图高度都是固定的,我需要将图像视图高度设置为与在线图像相同的图像高度。所以它可以取它的确切高度
【问题讨论】:
-
发布您的完整布局...代码
-
问题已更新,请检查