关闭

ID_ANDROID_CONTENT

标签: ID_ANDROID_CONTENTandroidgetWindowFLAG_FULLSCREENFEATURE_NO_TITLE
1563人阅读 评论(0) 收藏 举报
分类:

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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:7478次
    • 积分:60
    • 等级:
    • 排名:千里之外
    • 原创:3篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档
    最新评论