Comments (4)
是否图片过大,代码中display的时候没有传入高宽?
from volley.
加载14张网络图片,大小均为20K左右,排除图片过大的原因;使用四个参数的display方法传入宽高,在上下滑动的时候还是存在同样的问题。且重复滑动,消失图片的位置不同。怀疑是否为使用弱引用而没有使用LruCache的原因?
from volley.
代码中并没有使用弱引用来做缓存,是否方便提供部分代码?我本地测试一下
from volley.
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.ArrayList;
public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.RecycleViewHolder> {
private Context context;
private ArrayList<String> strings;
public RecycleAdapter(Context context, ArrayList<String> strings) {
this.context = context;
this.strings = strings;
}
@Override
public RecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.recycle_item, parent, false);
RecycleViewHolder holder = new RecycleViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(RecycleViewHolder holder, int position) {
MyApplication.getInstance().getBitmapTools().display(holder.img, strings.get(position));
}
@Override
public int getItemCount() {
return strings.size();
}
public class RecycleViewHolder extends RecyclerView.ViewHolder {
ImageView img;
public RecycleViewHolder(View itemView) {
super(itemView);
img = (ImageView) itemView.findViewById(R.id.img);
}
}
}
public class MainActivity extends ActionBarActivity {
private RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<String> strings = new ArrayList<>();
for (int i = 0; i < 3; i++) {
strings.add("http://g.hiphotos.baidu.com/image/w%3D310/sign=972b9e33324e251fe2f7e2f99786c9c2/0824ab18972bd407e3e5eff479899e510fb3099c.jpg");
strings.add("http://g.hiphotos.baidu.com/image/w%3D310/sign=0c1aeb23aad3fd1f3609a43b004f25ce/38dbb6fd5266d01687b5e625952bd40735fa350a.jpg");
strings.add("http://h.hiphotos.baidu.com/image/w%3D310/sign=42c9b52c9925bc312b5d07996ede8de7/9e3df8dcd100baa1a22d27594710b912c9fc2eca.jpg");
strings.add("http://a.hiphotos.baidu.com/image/w%3D310/sign=7b4616d4a964034f0fcdc4079fc27980/b999a9014c086e062d28e74200087bf40ad1cb33.jpg");
strings.add("http://c.hiphotos.baidu.com/image/w%3D310/sign=3915003f9045d688a302b4a594c37dab/024f78f0f736afc383d9f669b119ebc4b64512e1.jpg");
strings.add("http://e.hiphotos.baidu.com/image/w%3D310/sign=6366c3f20846f21fc9345852c6256b31/96dda144ad345982061b689b0ef431adcbef8422.jpg");
strings.add("http://c.hiphotos.baidu.com/image/w%3D310/sign=612b97dcfd039245a1b5e70eb795a4a8/aa64034f78f0f7360d262d100b55b319eac413c2.jpg");
}
recyclerView = (RecyclerView) findViewById(R.id.recycle);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
recyclerView.setAdapter(new RecycleAdapter(this, strings));
}
}
布局就不展示了,随便写一个就行。进入页面之后请上下重复滑动,中间部分有几张图片会消失。
from volley.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from volley.