Android屏幕全屏的实现代码
不久前,有位老友找到小编问道Android实现屏幕全屏?小编一时也愣了一下,现在得空就梳理一下,给出Android屏幕全屏的实现代码,希望能帮到更多的人,好啦,那接下来就随爱站技术小编一起往下学习吧。
去掉标题栏:
requestWindowFeature(Window.FEATURE_NO_TITLE);
API上是这么说的:
int FEATURE_NO_TITLE Flag for the "no title" feature, turning off the title at the top of the screen.
屏幕全屏:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
API上是这么说的:
int FLAG_FULLSCREEN Window flag: Hide all screen decorations (e.g.
屏幕没有边界限制(允许窗口扩展到屏幕外):
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
API上是这么说的:
int FLAG_LAYOUT_NO_LIMITS Window flag: allow window to extend outside of the screen.
用法:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
setContentView(R.layout.newslists);
newsListLayout = findViewById(R.id.newslistlayout);
newsListLayout.setBackgroundColor(Color.MAGENTA);
newsNameList = (ListView) findViewById(R.id.newsnamelist);
model = new Model(0, 6);
nameListAdapter = new NewsNameListAdapter(this, model);
newsNameList.setAdapter(nameListAdapter);
showPage = (TextView) findViewById(R.id.newslistshowpage);
updatePage(model.getIndex());
}
以上就是关于Android屏幕全屏的实现代码,如果大家还有疑问欢迎给我留言,小编会及时回复大家的,同时也非常感谢大家对爱站技术频道的支持!