小编Kir*_*dev的帖子

Android捏缩放大图像,内存高效而不丢细节

我的应用程序必须显示许多高分辨率图像(约1900*2200像素),支持捏缩放.为避免内存不足错误,我计划使用解码图像以显示全屏

options.inSampleSize = scale (scale was calculated as Power of 2 as Document)
Run Code Online (Sandbox Code Playgroud)

(我使用的观点是TouchImageView延伸的ImageView)

所以我可以快速加载图像并在屏幕(图像)之间平滑滑动.但是,当我捏​​缩放时,我的应用程序因缩放图像而丢失细节.如果我加载完整图像,我无法快速加载或平滑滑动,捏缩放后拖动.然后我尝试仅在用户开始捏缩放时加载完整图像,但由于图像非常大,我仍然无法平滑地拖动图像.Android画廊甚至可以完美地实现8Mpx图像.

任何人都可以帮助我.提前致谢

android out-of-memory large-files imageview pinchzoom

11
推荐指数
2
解决办法
3541
查看次数

当互联网连接丢失时,读取Inputstream不停止

我正在使用asynctask来下载文件.它正常工作,直到我关闭我的Android的wifi连接(没有其他互联网连接),仍然没有更改下载对话框.当我通过日志检查时,我发现输入流的函数read()是不停止的.那么如何检查这种情况呢?这是我的代码:

URL url = new URL(this.url);
        URLConnection connection = url.openConnection();
        connection.setReadTimeout(1000);
        connection.connect();
        // this will be useful so that you can show a typical 0-100% progress bar
        int fileLength = connection.getContentLength();
        fileName = "temp.zip";

        // download the file
        InputStream input = new BufferedInputStream(connection.getInputStream());
        OutputStream output = new FileOutputStream(path+fileName);

        byte buffer[] = new byte[1024000];
        long total = 0;
        int count;
        Log.v("test download:","download in background");
        while (((count = input.read(buffer)) != -1)) {
            Log.v("test download:","read:"+count);
            total += count;
            publishProgress((int) (total * 100 / …
Run Code Online (Sandbox Code Playgroud)

android inputstream android-asynctask

3
推荐指数
1
解决办法
1893
查看次数

在android主页小部件中获取TextView的文本(不在活动中)?

我刚开始使用Android主控件编程,所以我可以通过settextviewtext(),但是当我想从它那里得到的文本,我有没有理想的设置文本在家里小部件一个TextView从我的微件提供.不能像在activity中那样正常使用findViewById(),然后使用getText().有没有办法从widget提供程序中获取home widget中textview的文本?或者告诉我如何从其他活动中获得?

android widget textview

2
推荐指数
1
解决办法
2084
查看次数