当前位置: 编程技术>移动开发
本页文章导读:
▪使FrameLayout的Gravity即是Center 使FrameLayout的Gravity等于Center
由于无法设置FrameLayout的Gravity,所以只能通过重写onLayout事件实现居中的效果了
@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super..........
▪ 生成hprof 资料方法 生成hprof 文件方法
String packageName = getApplicationInfo().packageName; String hpFilePath = "/data/data/" + packageName + "/input.hprof"; try { // Debug.dumpHprofData("/sdcard/input.hprof"); Debug.dumpHprofData(hpFilePath); } ca.........
▪ 查看程序现阶段内存信息 查看程序当前内存信息
private void displayBriefMemory() { final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo(); activityManage.........
[1]使FrameLayout的Gravity即是Center
来源: 互联网 发布时间: 2014-02-18
使FrameLayout的Gravity等于Center
由于无法设置FrameLayout的Gravity,所以只能通过重写onLayout事件实现居中的效果了
由于无法设置FrameLayout的Gravity,所以只能通过重写onLayout事件实现居中的效果了
@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
// align child to center
int width = right - left;
int height = bottom - top;
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View childView = getChildAt(i);
if (childView.getVisibility() != View.GONE) {
final int childLeft = (width - childView.getWidth()) / 2;
final int childTop = (height - childView.getHeight()) / 2;
childView.layout(childLeft, childTop,
childLeft + childView.getWidth(),
childTop + childView.getHeight());
}
}
}
[2] 生成hprof 资料方法
来源: 互联网 发布时间: 2014-02-18
生成hprof 文件方法
String packageName = getApplicationInfo().packageName;
String hpFilePath = "/data/data/" + packageName + "/input.hprof";
try {
// Debug.dumpHprofData("/sdcard/input.hprof");
Debug.dumpHprofData(hpFilePath);
} catch (IOException e) {
e.printStackTrace();
}
String hpFilePath = "/data/data/" + packageName + "/input.hprof";
try {
// Debug.dumpHprofData("/sdcard/input.hprof");
Debug.dumpHprofData(hpFilePath);
} catch (IOException e) {
e.printStackTrace();
}
[3] 查看程序现阶段内存信息
来源: 互联网 发布时间: 2014-02-18
查看程序当前内存信息
private void displayBriefMemory() {
final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(info);
String tag = "====";
Log.i(tag, "系统剩余内存:" + (info.availMem >> 10) + "k");
Log.i(tag, "系统是否处于低内存运行:" + info.lowMemory);
Log.i(tag, "当系统剩余内存低于" + info.threshold + "时就看成低内存运行");
}
private void displayBriefMemory() {
final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(info);
String tag = "====";
Log.i(tag, "系统剩余内存:" + (info.availMem >> 10) + "k");
Log.i(tag, "系统是否处于低内存运行:" + info.lowMemory);
Log.i(tag, "当系统剩余内存低于" + info.threshold + "时就看成低内存运行");
}
最新技术文章: