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背景
- ID_ANDROID_CONTENT
- Android基于Window.ID_ANDROID_CONTENT给定id添加子View
- Android基于Window.ID_ANDROID_CONTENT给定id添加子View
- 在linux下用tomcat部署java web项目的过程与注意事项
- Xcode6之后添加 .pch 文件
- 【Leet Code】80. Remove Duplicates from Sorted Array II---Medium
- Kibana User Guide [4.2] » Introduction
- 浅谈如何提高服务器并发处理能力(来自某位大牛的博客)
- ID_ANDROID_CONTENT
- iOS应用国际化教程(2014版)
- VMWare 解决“intel VT-x 处于禁用状态”的问题
- My deep learning reading list
- Android 四大组件之Service 生命周期
- ObReferenceObjectByHandle例程
- javaweb学习笔记_day1
- 浅谈Java Interface
- SSL 之根证书