android 常用UI使用工具代码片段
来源:互联网 发布:百度解压缩软件 编辑:程序博客网 时间:2024/05/16 00:41
/*
* 常用UI使用工具
*/
//***与像素密度无关的触控笔势
private static final float DISTANCE_DIP = 16.0f;
private static final float PATH_DIP = 40.0f;
// convert dip measurements to pixels
final float scale = getResources().getDisplayMetrics().density;
int scaledDistance = (int) (DISTANCE_DIP * scale + 0.5f);
int scaledPath = (int) (PATH_DIP * scale + 0.5f);
// For more information about touch gestures and screens support, see:
// http://developer.android.com/resources/articles/gestures.html
// http://developer.android.com/reference/android/gesture/package-summary.html
// http://developer.android.com/guide/practices/screens_support.html
//***缩放位图以查看大小
originalImage = Bitmap.createScaledBitmap(
originalImage, // bitmap to resize
view.getWidth(), // new width
view.getHeight(), // new height
true); // bilinear filtering
//***调整widget大小
public void onSizeChanged(int w, int h, int oldW,
int oldH) {
// Calculate relative sizes at runtime
// mButton and mButtonBackGround are of type Drawable
int selfW = mButton.getIntrinsicWidth();
int selfH = mButton.getIntrinsicHeight();
int marginX = (w - selfW) / 2;
int marginY = (h - selfH) / 2;
mButtonBackground.setBounds(marginX, marginY,
marginX + selfW, marginY + selfH);
mButton.setBounds(marginX, marginY,
marginX + selfW, marginY + selfH);
// Implement the measureText method to resize text data, if applicable
measureText();
}
//***响应widget交互
// Add import android.view.View.OnClickListener; statement
// Add import android.widget.Button; statement
// Add import android.view.View; statement
Button b1 = (Button) findViewById(R.id.your_button_id); // Use this method carefully, it consumes lots of system resources
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Handle the button click here as you wish
}
});
- android 常用UI使用工具代码片段
- android常用代码片段
- android常用代码片段
- android常用代码片段
- Android常用代码片段
- Android 常用代码片段
- android常用代码片段
- Android常用代码片段
- 常用android代码片段
- android 常用代码片段
- Android 常用代码片段
- android 常用代码片段
- android 常用代码片段
- Android常用代码片段
- android开发常用代码片段
- Android 开发常用代码片段
- Android 开发常用代码片段
- Android 开发常用代码片段
- MySQL Query:show columns from user_lucene from ptv MySQL Error:Can't open file: '*.ibd' (errno: 1) MySQL Errno:1016 Message:
- ubuntu忘记密码,忘记root密码的解决方法!【转载】
- Database connection in SOAP UI
- 两道选择题
- oracle 包 (package)
- android 常用UI使用工具代码片段
- iphone绘图基础
- 关于mysql大批量数据导入相关my.cnf参数设置
- MYSQL group by 语句中的with rollup是用来干什么的?
- 类的加载笔记
- 黄子华 奸人坚语录
- android 传感器
- Linux下如何统计文件数目
- android Web和Web服务