【发布时间】:2017-10-17 15:09:26
【问题描述】:
我想模糊一个 ListView 项目。我在 CustomListViewAdapter 的 getView() 中模糊(使用 Blurry 库):
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
final AirdropResult airdrop = getItem(position);
boolean bWasNull = false;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.result_item, parent, false);
bWasNull = true;
}
final RelativeLayout airdropListRowInside = (RelativeLayout) convertView.findViewById(R.id.airdropListRowInside);
final TextView tvName = (TextView) airdropListRowInside.findViewById(R.id.tvCoinName);
final TextView tvDesc = (TextView) airdropListRowInside.findViewById(R.id.tvDesc);
final TextView tvStartdate = (TextView) airdropListRowInside.findViewById(R.id.tvStartdate);
tvName.setText(airdrop._name);
tvDesc.setText(airdrop._shortdesc);
if(bWasNull) {
convertView.post(new Runnable() {
@Override
public void run() {
Blurry.with(getContext())
.radius(5)
.sampling(2)
.async()
.animate(100)
.onto(airdropListRowInside);
}
});
}
return convertView;
}
似乎布局变得模糊,但随后它在顶部呈现非模糊布局(只有一种布局)。我使用了 Runnable because it is apparently needed。
我假设这是因为 ListView 如何重用项目但没有足够的理解来解决它。有人可以帮忙吗?
【问题讨论】:
-
发布完整的
getView()方法 -
已发布完整实施。
标签: android listview blur blurry