码迷,mamicode.com
首页 > 移动开发 > 详细

android studio Activity标题研究

时间:2016-07-30 19:38:33      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

第一次研究时间:2016/7/30

一、头部标题取消

当前版本新建工程在 application中默认主题为 android:theme="@style/AppTheme" ,存在于res/values/styles.xml中代码,此为默认创建时不同版本可能不一样

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

取消标题方式:

1、全部取消主题,android:theme=""输入@style/No查询,这边出现以下三个,应该选哪个都可以,等做的时候不行再换

技术分享
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:theme="@style/Theme.AppCompat.NoActionBar"
View Code

2、单个取消主题,就是在<activity 便签中同样存在android:theme="",里面的值同上

   在代码中取消标题,在android studio中使用,eclipse看下方代码:

技术分享
//请将以下代码写在 setContentView() 前面
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
View Code

     在eclipse中使用这个

技术分享
requestWindowFeature(Window.FEATURE_NO_TITLE);
View Code

  附带取消头部状态栏代码,状态栏为最上面的小黑条,显示着时间,电量什么的,手指按住可以下拉,eclipse下同

技术分享
//同样写在setContentView()之上
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
View Code

而网上使用以下标签来同时消除标题跟状态栏只有在文件 extends Activity时是有用的,在继承AppCompatActivity或者ActionBarActivity闪退,原因请看链接

http://www.eoeandroid.com/thread-559545-1-1.html?_dsign=51bbc2e6

技术分享
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
View Code

 

二、标题栏设计

android studio Activity标题研究

标签:

原文地址:http://www.cnblogs.com/minyc/p/5721438.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!