android瀑布流
16lz
2021-01-24
Android瀑布流
写一个瀑布流很简单,但是简单的瀑布流也是有一些需要解决的问题,最常见的问题OOM ,图片一旦加载多程序就会崩溃,本工具库使用,SCrollView+LinearLayout实现瀑布流,完美解决oom ,只加载屏幕范围类的图片,图片存在则缓存加载 ,工具经过多次测试,大部分BUG已经解决,
工具库+dome下载 工具库(the_waterfall_flow_view)
http://download.csdn.net/detail/qq_18420641/9879236
运行效果图;
工具库说明
the_waterfall_flow_view 文件中有三个包
1 .call_activity;
flass_img_show.java
2 .dome(封装所需要的对象)
h_w_dome.java
ISmartScrollChangedListener.java
value_dome.java
3.util
falls_img_loder_util.java
myImgeView.java
MyScrollView.java
功能实现实例代码
package test_view;
import java.util.ArrayList;
import java.util.List;
import com.example.test_view.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import call_activity.flass_img_show;
import dome.value_dome;
public class test_avtivity extends Activity {
LinearLayout lift_img;
LinearLayout center_img;
LinearLayout rigt_img;
value_dome dome;
util.MyScrollView scr_view;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test_avtivity_layout);
scr_view = (util.MyScrollView) findViewById(R.id.scr_view);
lift_img = (LinearLayout) findViewById(R.id.lift_img);
center_img = (LinearLayout) findViewById(R.id.center_img);
rigt_img = (LinearLayout) findViewById(R.id.rigt_img);
List
url.add("http://img.hb.aicdn.com/0f553ccde2d182b841eb515bd3dc8e5c3e4055f8837b4-g5JDNR_fw658");
url.add("http://img.hb.aicdn.com/d2d1e96f9ba2f2dc899100afbb046fe02aa682275d8b2-AhseJV_fw658");
url.add("http://img.hb.aicdn.com/05f503e79e197232ac0675f4639cd7459ab4b327bdf37-3HoX31_fw658");
/**
* 参数说明 columnNum 每一次取出多少张图片添加到视图中 img_url 图片的url集合 context上下文
* lift_img,center_img,rigt_img为三个LinearLayout mSmartScrollChangedListener
* 对状态的接口回调(1。ScrollView 滑动到top 2 ScrollView 滑动bottom
* 3,滑动效果是否停止,并判断其中是否有子view到了底部 )
**/
scr_view.showWaterfallView(10, url, test_avtivity.this, lift_img, center_img, rigt_img,
new dome.ISmartScrollChangedListener() {
//是否滚动到top
@Override
public void onScrolledToTop() {
}
//是否滚动到bottom
@Override
public void onScrolledToBottom() {
// TODO Auto-generated method stub
}
//是否停止了滚动 ,有没有到达其中一个子view的底部
@Override
public void onScrollStop(boolean ifScrollStop, boolean ifchildShow) {
// TODO Auto-generated method stub
}
});
}
}
布局文件.xml
<?xml version="1.0" encoding="utf-8"?>
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
更多相关文章
- Android开源项目--工具库篇
- ANDROID自动化测试工具:ROBOTIUM
- android 自定义RadioButton样式
- 转:关于android中图片裁剪以及PorterDuffXfermode的使用经验小结
- Android底部菜单的实现
- Android——adb工具的使用
- Android(安卓)NDK: Host 'awk' tool is outdated.
- android中Bitmap数据如何释放
- Android(安卓)Glide加载图片圆角效果与ImageView的ScaleType冲突