/** * 设置控件位置大小(主方法) * * @author ren */ protected void postView(int w, int h) { // 背景大小 LayoutParams para1; para1 = backImg.getLayoutParams(); para1.height = w / 3; para1.width = w; backImg.setLayoutParams(para1); // 头像大小 para1 = userHead.getLayoutParams(); para1.height = (int) (1.01 * 4 * w / 18); para1.width = (int) (1.01 * 4 * w / 18); userHead.setLayoutParams(para1); // 头像大小 para1 = hb1.getLayoutParams(); para1.height = (int) (1.04 * 4 * w / 18); para1.width = (int) (1.04 * 4 * w / 18); hb1.setLayoutParams(para1); // 基本信息(按顺序) para(sign1); para(nickname1); para(realname1); para(sex1); para(xi1); para(grade1); para(say1); para(mail1); para(tele1); para(qq1); }
/** * 获取图片 * * @author ren */ private void getImage() { // TODO Auto-generated method stub SharedPreferences sp = this.getSharedPreferences("SP" + userID, Context.MODE_PRIVATE); int backChange = sp.getInt("back", 0); // 保存图片更换信息(0为未更换,1为更换) int headChange = sp.getInt("head", 0); b = false; if (backChange == 0) { // 默认系统图片 backImg.setBackgroundResource(R.drawable.personal_backg1); } else if (backChange == 1) { // 自定义图片 String path1 = Environment.getExternalStorageDirectory().getPath() + "/NewLab/Background/"; Bitmap bt1 = BitmapFactory.decodeFile(path1 + picB); // 本地背景图片地址及获取 if (bt1 != null) { @SuppressWarnings("deprecation") Drawable drawable = new BitmapDrawable(bt1); // 背景 backImg.setImageDrawable(drawable); } else { b = true; } } if (headChange == 0) { userHead.setImageDrawable( this.getResources().getDrawable(R.drawable.personal_head1)); // 默认系统图片 } else if (headChange == 1) { // 自定义图片 String path2 = Environment.getExternalStorageDirectory().getPath() + "/NewLab/Head/"; Bitmap bt2 = BitmapFactory.decodeFile(path2 + picH); // 本地头像图片地址及获取 if (bt2 != null) { @SuppressWarnings("deprecation") Drawable drawable = new BitmapDrawable(bt2); // 头像 userHead.setImageDrawable(drawable); } else { b = true; } } if (b) { clickable(b); // 设置按钮不可点击 GreatToastShow.Toast(this, "我去,图片咧!重新设置一下吧!", "#ff669900", 50, 100, Effects.thumbSlider); Handler handler = new Handler(); handler.postDelayed( new Runnable() { @Override public void run() { clickable(false); b = false; } }, 2700); } }