ID_ANDROID_CONTENT

来源:互联网 发布:苹果app下载不了软件 编辑:程序博客网 时间:2024/04/29 21:11

ID_ANDROID_CONTENT:The ID that the main layout in the XML layout file should have(XML中显示区域根视图的ID值,该视图由系统自动生成,未在XML中定义)


getTop、getBottom、getLeft、getRight:视图相对于父视图的位置


代码实例:

public class MainActivity extends Activity {

TextView mTextView;

Handler mHandler = new Handler() {

@Override

public void handleMessage(Message msg) {

if(msg.what == 0) {

int contentTop1 = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();

Log.e("wangzihan","" + contentTop1);

int contentTop2 = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getBottom();

Log.e("wangzihan","" + contentTop2);

int contentTop3 = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getLeft();

Log.e("wangzihan","" + contentTop3);

int contentTop4 = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getRight();

Log.e("wangzihan","" + contentTop4);

Rect frame = new Rect();

mTextView.getWindowVisibleDisplayFrame(frame);

Log.e("wangzihan"," " + frame.top + "  " + frame.bottom + " " + frame.left + " " + frame.right);

}

}

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.activity_main);

mTextView = (TextView)findViewById(R.id.a);

mHandler.sendEmptyMessageDelayed(0,1000);

}

}

// requestWindowFeature(Window.FEATURE_NO_TITLE);

// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

输出结果为

204

1920

0

1024

60  1920  0  1024

requestWindowFeature(Window.FEATURE_NO_TITLE);

// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

输出结果:

60

1920

0

1024

60  1920  0  1024


//requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

输出结果为

144

1920

0

1080

0  1920  0  1080


requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

输出结果为

0

1920

0

1080

0  1920  0  1080


int contentTop1 = getWindow().getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();

Log.e("wangzihan","" + contentTop1);


int contentTop2 = getWindow().getWindow().findViewById(Window.ID_ANDROID_CONTENT).getBottom();

Log.e("wangzihan","" + contentTop2);


int contentTop3 = getWindow().getWindow().findViewById(Window.ID_ANDROID_CONTENT).getLeft();

Log.e("wangzihan","" + contentTop3);


int contentTop4 = getWindow().getWindow().findViewById(Window.ID_ANDROID_CONTENT).getRight();

Log.e("wangzihan","" + contentTop4);


Rect frame = new Rect();

mInputView.getWindowVisibleDisplayFrame(frame);

Log.e("wangzihan"," " + frame.top + "  " + frame.bottom + " " + frame.left + " " + frame.right);


Log.e( "wangzihan","" + getWindow().getWindow().getDecorView().getTop() );

Log.e( "wangzihan","" + getWindow().getWindow().getDecorView().getBottom() );

Log.e( "wangzihan","" + getWindow().getWindow().getDecorView().getLeft() );

Log.e( "wangzihan","" + getWindow().getWindow().getDecorView().getRight() );


--------------------------------- 普通activity 有状态栏、标题栏

204

1920

0

1080

60 1920 0 1080

0

1920

0

1080

--------------------------------- 输入法 界面

0

731

0

1080

60 1920 0 1080

0

731

0

1080

getWindow().getWindow().getDecorView().setBackgroundDrawable(getResources().getDrawable(R.drawable.girl));  设置输入法window背景


1 0
原创粉丝点击