0
点赞
收藏
分享

微信扫一扫

解决recyclerview 第一次加载固定的item 不显示的问题


这个问题的原因是

item的布局没有设置具体宽高,先指定宽高,如果还要再计算宽高可以在onbindView中再计算设置

 

ImageView img1 =  holder.findViewById(R.id.img1);
LinearLayout content= holder.findViewById(R.id.content);
int width= ((ScreenUtils.getScreenWidth(SuggestionActivity.this)-ScreenUtils.dip2px(SuggestionActivity.this,50))/4);
LinearLayout.LayoutParams layoutParams= new LinearLayout.LayoutParams(width,width);
img1.setLayoutParams(layoutParams);
content.setLayoutParams(layoutParams);

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:id="@+id/content"
android:orientation="vertical">

<ImageView
android:id="@+id/img1"
android:layout_width="60dp"
android:layout_height="60dp"
/>


</LinearLayout>

 

举报

相关推荐

算法问题-第一次课程

sql第一次

记csdn的第一次

MYSQL的第一次作业

第一次见到的车

记录第一次

第一次打卡

0 条评论