ListView
에 행을 덮는 ImageView
이 있습니다. (나는 Picasso로 이미지를로드하고 있는데, 우선 글라이딩을 시도했지만 Picasso가 약간 빠름) 롤리팝과 kitkat에서 원활하게 작동하지만 marshmallow에서 스크롤이 매우 느리게 진행되고 ANR 메시지가 표시되는 경우가 있습니다.ListView scroll in marshmallow 이미지가 느려짐
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="170dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/img_genre_bg"
android:scaleType="fitXY"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--android:background="@color/trans_black"-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img_play"
android:layout_centerHorizontal="true"
android:src="@drawable/play_button"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_genre_name"
android:textSize="20sp"
android:textAllCaps="true"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:layout_below="@+id/img_play"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_genre_id"
android:visibility="gone"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@color/colorAccent"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
목록보기 :
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lv_genre"
android:scrollbars="none"
android:divider="@null"
android:cacheColorHint="@android:color/transparent"
android:fastScrollEnabled="true"
android:persistentDrawingCache="scrolling"
android:scrollingCache="false">
</ListView>
의 getView() :
다음은 목록 항목에 대한 내 XML이다
public View getView(int position, View view, ViewGroup viewGroup) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowview=view; if(rowview==null){ rowview=inflater.inflate(R.layout.item_genre_list,viewGroup,false); } id = (TextView) rowview.findViewById(R.id.tv_genre_id); TextView name = (TextView) rowview.findViewById(R.id.tv_genre_name); ImageView img_genre_bg = (ImageView) rowview.findViewById(R.id.img_genre_bg); ImageView img_play = (ImageView) rowview.findViewById(R.id.img_play); opensans = Typeface.createFromAsset(context.getAssets(), "font/OpenSans-Light.ttf"); name.setTypeface(opensans); GENRE genre=new GENRE(); genre=genres.get(position); id.setText(genre.getGenre_id()); name.setText(genre.getGenre_name()); Picasso .with(context) .load(genre.getGenre_image()) .placeholder(R.drawable.loading) .into(img_genre_bg); return rowview; }
별도의 AsyncTask
스레드에서 이미지로드를 시도했지만 여전히 스크롤이 멈추었습니다. RecyclerView
으로 변경해도 도움이되지 않았습니다.
당신은'ViewHolder' 패턴을 사용하지 않고 모든 행이 생성되는 동안 서체를 생성합니다. – kId