ID_ANDROID_CONTENT

原创 2015年11月18日 15:20:49

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背景


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Android点滴(二)

如何获取状态栏和标题栏的高度? 1.获取状态栏高度: decorView是window中的最顶层view,可以从window中获取到decorView,然后decorView有个getWindow...

android状态栏一体化(沉浸式状态栏)

Android 沉浸式状态栏、状态栏一体化、透明状态栏、仿ios透明状态栏  http://blog.csdn.net/jdsjlzx/article/details/50437779 注...
  • jhl122
  • jhl122
  • 2016-09-18 16:01
  • 1069

android.content.res.Resources$NotFoundException: Resource ID #0x7f09000a type #0x12 is not valid

1.出现错误如下:2.分析:找不到XML资源: 网上找了一圈,大多是告诉你XML有编译期的错误,没有显示出来,如代码残缺,索引资源有问题,图片,字符,样式等等,如果是如此的问题,去一个个排查就好了,...

APK签名android.content.res.Resources$NotFoundException resource ID #0x7f060000

What steps will reproduce the problem? 1. Decode an app with a raw resource (such as an MP3) 2. Buil...
  • WHACKW
  • WHACKW
  • 2015-02-05 18:17
  • 1133

android.content.res.Resources$NotFoundException: Resource ID #0x7f030002

1、错误产生 今天写了小demo,想预览下

Android使用TabHost程序异常终止could not create tab content because could not find view with id 错误

Android使用TabHost程序异常终止could not create tab contentbecause could not find view with id 。。。错误 我试验Ta...

[content-description] find_element_by_accessibility_id 在 android 中的详解

最近 Appium 引入了一个新的 find element 方法:python client 为例 def find_element_by_accessibility_id(self, i...

android.content.res.Resources$NotFoundException: String resource ID #0x6错误的解决办法

在开发过程当中遇到这个问题 08-17 18:12:24.835: E/AndroidRuntime(17951): FATAL EXCEPTION: main 08-17 18:12:24.8...

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0

E/AndroidRuntime(1288): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)