android屏幕全屏的实现代码

2016-02-19 09:45 20 1 收藏

图老师设计创意栏目是一个分享最好最实用的教程的社区,我们拥有最用心的各种教程,今天就给大家分享android屏幕全屏的实现代码的教程,热爱PS的朋友们快点看过来吧!

【 tulaoshi.com - 编程语言 】

去掉标题栏:
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());
     }

来源:https://www.tulaoshi.com/n/20160219/1591973.html

延伸阅读
大致上,我们发现,下拉刷新的列表和一般列表的区别是,当滚动条在顶端的时候,再往下拉动就会把整个列表拉下来,显示出松开刷新的提示。由此可以看出,在构建这个下拉刷新的组件的时候,只用继承ListView,然后重写onTouchEvent就能实现。还有就是要能在xml布局文件中引用,还需要一个参数为Context,AttributeSet的构造函数。 表...
代码如下: StringBuilder phoneInfo = new StringBuilder(); phoneInfo.append("Product: " + android.os.Build.PRODUCT + System.getProperty("line.separator")); phoneInfo.append( "CPU_ABI: " + android.os.Build.CPU_ABI + System.getProperty("line.separator")); phoneInfo.append( "TAGS: " + android.os.Build.TAGS + System.ge...
代码如下: // 隐藏输入法 InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); // 显示或者隐藏输入法 imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); toggleSoftInput 这个方法可以转换软件输入法在窗体中的显示状态。如果输入法当前是显示状...
在做多语言版本的时候,日期时间的格式话是一个很头疼的事情,幸好Android提供了DateFormate,可以根据指定的语言区域的默认格式来格式化。 直接贴代码: 代码如下: public static CharSequence formatTimeInListForOverSeaUser( final Context context, final long time, final boolean simple, Locale locale) { final GregorianCale...
实现手机电话状态的监听,主要依靠两个类:TelephoneManger和PhoneStateListener。 TelephonseManger提供了取得手机基本服务的信息的一种方式。因此应用程序可以使用TelephonyManager来探测手机基本服务的情况。应用程序可以注册listener来监听电话状态的改变。我们不能对TelephonyManager进行实例化,只能通过获取服务的形式: Context.getSy...

经验教程

147

收藏

88
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部