首页 文章 精选 留言 我的

精选列表

搜索[按需加载],共10005篇文章
优秀的个人博客,低调大师

Glide 加载图片背景变绿

Glide使用bitmap的编码问RGB565,所以有时的时候由于过度压缩导致了图片变绿。 所以要改变一下Glide的bitmap编码。 import android.content.Context; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.load.DecodeFormat; import com.bumptech.glide.module.GlideModule; /** * Created by zhaoyong on 2016/1/26. * 增加图片清晰度 */ public class GlideConfiguration implements GlideModule{ @Override public void applyOptions(Context context, GlideBuilder builder) { builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); } @Override public void registerComponents(Context context, Glide glide) { } } 然后AndroidManifext中: <meta-data android:name="com.xxx.xxx.xxx.GlideConfiguration" android:value="GlideModule"/> ,如需转载请自行联系原作者

优秀的个人博客,低调大师

android 启动延迟加载画面

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 LoginActivity package com.xkhouse.erm.erm; import android.app.Activity; import android.os.Bundle; import android.view.Window; /*publicclassLoginActivityextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ //requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); } }*/ publicclassLoginActivityextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); /* *设置隐藏标题栏 */ requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_login); } } /*publicclassSplashActivityextendsActivity{ privatefinalintSPLASH_DISPLAY_LENGHT=1000;//延迟一秒 @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.jiazai); newHandler().postDelayed(newRunnable(){ //为了减少代码使用匿名Handler创建一个延时的调用 publicvoidrun(){ Intenti=newIntent(SplashActivity.this,LoginActivity.class); //通过Intent打开最终真正的主界面Main这个Activity SplashActivity.this.startActivity(i);//启动Main界面 SplashActivity.this.finish();//关闭自己这个开场屏 } },SPLASH_DISPLAY_LENGHT); } }*/ SplashActivity packagecom.xkhouse.erm.erm; importandroid.app.Activity; importandroid.content.Intent; importandroid.os.Bundle; importandroid.os.Handler; importandroid.view.Window; importandroid.view.WindowManager; /*publicclassSplashActivityextendsActivity{ privatefinalintSPLASH_DISPLAY_LENGHT=6000;//延迟六秒 @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.splash); newHandler().postDelayed(newRunnable(){ publicvoidrun(){ IntentmainIntent=newIntent(SplashActivity.this, LoginActivity.class); SplashActivity.this.startActivity(mainIntent); SplashActivity.this.finish(); } },SPLASH_DISPLAY_LENGHT); } }*/ publicclassSplashActivityextendsActivity{ finalprivateintSPLASH_TIME=1000; @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); /* *设置全屏 */ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); /* *设置隐藏标题栏 */ requestWindowFeature(Window.FEATURE_NO_TITLE); /* *2秒后跳转到主界面 */ newHandler().postDelayed(newRunnable(){ publicvoidrun(){ launchMainActivity(); } },SPLASH_TIME); setContentView(R.layout.activity_splash); } /* *利用Intent切换到主Activity */ privatevoidlaunchMainActivity(){ /* *创建一个intent,从当前Activity指向要跳转的Activity */ Intentintent=newIntent(this,LoginActivity.class); /* *启动目标Activity */ startActivity(intent); /* *启动画面只需要程序开始时显示一次,显示完后即可退出 */ finish(); } } layout目录下 activity_splash.xml <?xmlversion= "1.0" encoding= "utf-8" ?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_height= "fill_parent" android:layout_width= "fill_parent" android:orientation= "vertical" > <ImageViewandroid:layout_height= "fill_parent" android:layout_width= "fill_parent" android:scaleType= "fitCenter" android:src= "@drawable/splash" ></ImageView> </LinearLayout> AndroidMainfest.xml <?xmlversion= "1.0" encoding= "utf-8" ?> <manifestxmlns:android= "http://schemas.android.com/apk/res/android" package = "com.xkhouse.erm.erm" > <application android:allowBackup= "true" android:icon= "@drawable/logo" android:label= "@string/app_name" android:theme= "@android:style/Theme.NoTitleBar.Fullscreen" > <activity android:name= "com.xkhouse.erm.erm.SplashActivity" android:label= "@string/app_name" > <intent-filter> <actionandroid:name= "android.intent.action.MAIN" /> <categoryandroid:name= "android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activityandroid:name= ".LoginActivity" ></activity> </application> </manifest> 本文转自 liang3391 51CTO博客,原文链接:http://blog.51cto.com/liang3391/1631840

优秀的个人博客,低调大师

android:通过URL加载ImageView

iphone上实现很简单,一行代码: imageView.image=[UIImageimageWithContentsOfURL:theURL]; android: 两种方法: Bitmap bimage= getBitmapFromURL(bannerpath); image.setImageBitmap(bimage); public static Bitmap getBitmapFromURL(String src) { try { Log.e("src",src); URL url = new URL(src); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); Bitmap myBitmap = BitmapFactory.decodeStream(input); Log.e("Bitmap","returned"); return myBitmap; } catch (IOException e) { e.printStackTrace(); Log.e("Exception",e.getMessage()); return null; } } or try it public static Bitmap loadBitmap(String url) { Bitmap bitmap = null; InputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new URL(url).openStream(), IO_BUFFER_SIZE); final ByteArrayOutputStream dataStream = new ByteArrayOutputStream(); out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE); copy(in, out); out.flush(); final byte[] data = dataStream.toByteArray(); BitmapFactory.Options options = new BitmapFactory.Options(); //options.inSampleSize = 1; bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options); } catch (IOException e) { Log.e(TAG, "Could not load Bitmap from: " + url); } finally { closeStream(in); closeStream(out); } return bitmap; } 方法2 Drawable drawable = LoadImageFromWebOperations(bannerpath); image.setImageDrawable(drawable); private Drawable LoadImageFromWebOperations(String url) { try { InputStream is = (InputStream) new URL(url).getContent(); Drawable d = Drawable.createFromStream(is, "src name"); return d; }catch (Exception e) { System.out.println("Exc="+e); return null; } } 搞定! 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/05/24/2515913.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册