当前位置: 编程技术>移动开发
本页文章导读:
▪TableLayout失去TableRow TableLayout得到TableRow
for(int i = 0, j < table.getChildCount(); i < j; i++){ // then, you can remove the the row you want... // for instance... TableRow row = getChildAt(i); if( something you want to check ) { .........
▪ 经过图标发起安装的程序 通过图标发起安装的程序
在主menu菜单中 只要拉开点击里面的图标就会响应程序
主要用到
public static Intent getLaunchIntent(String packageName, String className) { Intent intent = new Intent(ACTION_MAIN); .........
▪ 获取状态栏跟标题栏的的高度 获取状态栏和标题栏的的高度
代码是参考某位仁兄的片段,以下是可行的完整测试代码:package com.aslibra.test;import android.app.Activity;import android.graphics.Rect;import android.os.Bundle;import android.util.Lo.........
[1]TableLayout失去TableRow
来源: 互联网 发布时间: 2014-02-18
TableLayout得到TableRow
for(int i = 0, j < table.getChildCount(); i < j; i++){
// then, you can remove the the row you want...
// for instance...
TableRow row = getChildAt(i);
if( something you want to check ) {
removeViewAt(i);
// or...
removeView(row);
}
}
[2] 经过图标发起安装的程序
来源: 互联网 发布时间: 2014-02-18
通过图标发起安装的程序
在主menu菜单中 只要拉开点击里面的图标就会响应程序
主要用到
public static Intent getLaunchIntent(String packageName, String className) {
Intent intent = new Intent(ACTION_MAIN);
intent.addCategory(CATEGORY_LAUNCHER);
intent.setClassName(packageName, className);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK
| FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
return intent;
}
[3] 获取状态栏跟标题栏的的高度
来源: 互联网 发布时间: 2014-02-18
获取状态栏和标题栏的的高度
代码是参考某位仁兄的片段,以下是可行的完整测试代码:
package com.aslibra.test;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.ImageView;
public class test extends Activity {
ImageView iv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iv = (ImageView) this.findViewById(R.id.ImageView01);
iv.post(new Runnable()
{
public void run()
{
viewInited();
}
}
);
Log.v("test", "== ok ==");
}
private void viewInited(){
Rect rect= new Rect();
Window window= getWindow();
iv.getWindowVisibleDisplayFrame(rect);
int statusBarHeight= rect.top;
int contentViewTop= window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;
//测试结果:ok之后 100多 ms 才运行了
Log.v("test", "=-init-= statusBarHeight="+statusBarHeight+
" contentViewTop="+contentViewTop+
" titleBarHeight="+titleBarHeight);
}
/*
* 07-14 02:36:48.449: VERBOSE/test(1385): == ok ==
* 07-14 02:36:48.558: VERBOSE/test(1385): =-init-= statusBarHeight=25 contentViewTop=50 titleBarHeight=25
*/
}
浏览器获取状态栏高度的代码
Rect visRect = new Rect();
if (!mBrowserFrameLayout.getGlobalVisibleRect(visRect)) {
if (LOGD_ENABLED) {
Log.d(LOGTAG, "showFakeTitleBar visRect failed");
}
return;
}
params.y = visRect.top;
代码是参考某位仁兄的片段,以下是可行的完整测试代码:
package com.aslibra.test;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.ImageView;
public class test extends Activity {
ImageView iv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iv = (ImageView) this.findViewById(R.id.ImageView01);
iv.post(new Runnable()
{
public void run()
{
viewInited();
}
}
);
Log.v("test", "== ok ==");
}
private void viewInited(){
Rect rect= new Rect();
Window window= getWindow();
iv.getWindowVisibleDisplayFrame(rect);
int statusBarHeight= rect.top;
int contentViewTop= window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;
//测试结果:ok之后 100多 ms 才运行了
Log.v("test", "=-init-= statusBarHeight="+statusBarHeight+
" contentViewTop="+contentViewTop+
" titleBarHeight="+titleBarHeight);
}
/*
* 07-14 02:36:48.449: VERBOSE/test(1385): == ok ==
* 07-14 02:36:48.558: VERBOSE/test(1385): =-init-= statusBarHeight=25 contentViewTop=50 titleBarHeight=25
*/
}
浏览器获取状态栏高度的代码
Rect visRect = new Rect();
if (!mBrowserFrameLayout.getGlobalVisibleRect(visRect)) {
if (LOGD_ENABLED) {
Log.d(LOGTAG, "showFakeTitleBar visRect failed");
}
return;
}
params.y = visRect.top;
最新技术文章: