Android状态栏一体化 (改变状态栏的背景颜色)

来源:互联网 发布:字符能遍历吗python 编辑:程序博客网 时间:2024/06/09 19:55

1、前言

在android kitkat 有一个新的特性可以设置手机状态栏的背景,让手机整个界面的风格保持一致,看起来非常清爽,在今年的google i/o上的android l默认就是这种风格。来现在看我们怎么加上这个酷黑狂拽掉渣天的功能怎么给我们的程序加上。来先看一下demo效果图。



2、关与kitkat


android 4.4 提供了一套能透明的系统ui样式给状态栏和导航栏,这样的话就不用向以前那样每天面对着黑乎乎的上下两条黑栏了,还可以调成跟activity 一样的样式,形成一个完整的主题。


3、设置方法


首先要打开activity的透明主题功能,可以把activity的主题设置继承*.TranslucentDecor 主题,然后设置android:windowTranslucentNavigation 或者android:windowTranslucentStatus的主题属性为true,又或者在activity的代码里面开启FLAG_TRANSLUCENT_NAVIGATION 或是 FLAG_TRANSLUCENT_STATUS的window窗口标识由于透明主题不能在4.4以前的版本里面使用,所以系统样式跟以前没有区别,也就是看不到任何变化,这是一个兼容模式,这个模式可以兼容到api 10.


激活主题

[java] view plaincopy
  1. @Override  
  2. protected void onCreate(Bundle savedInstanceState) {  
  3.     super.onCreate(savedInstanceState);  
  4.     setContentView(R.layout.activity_main);  
  5.     // 创建状态栏的管理实例  
  6.     SystemBarTintManager tintManager = new SystemBarTintManager(this);  
  7.     // 激活状态栏设置  
  8.     tintManager.setStatusBarTintEnabled(true);  
  9.     // 激活导航栏设置  
  10.     tintManager.setNavigationBarTintEnabled(true);  
  11. }  

设置状态栏颜色和图片


[java] view plaincopy
  1. // 设置一个颜色给系统栏  
  2. tintManager.setTintColor(Color.parseColor("#99000FF"));  
  3. // 设置一个样式背景给导航栏  
  4. tintManager.setNavigationBarTintResource(R.drawable.my_tint);  
  5. // 设置一个状态栏资源  
  6. tintManager.setStatusBarTintDrawable(MyDrawable);  


4、开源下载地址

https://github.com/hexiaochun/SystemBarTint


状态栏的字体颜色位白色, 如果状态栏背景为白色,这个怎么解决呢?下面这个博客解决了这个问题。

http://blog.csdn.net/jdsjlzx/article/details/50437779









===================


这个特性是andorid4.4支持的,最少要api19才可以使用。


开启FLAG_TRANSLUCENT_NAVIGATION 或是 FLAG_TRANSLUCENT_STATUS

int API_LEVEL =  android.os.Build.VERSION.SDK_INT;if (API_LEVEL >= 19){    getWindow().addFlags( WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION );     }

  1.      //透明状态栏  
  2.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  3.         //透明导航栏  
  4.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  


状态栏设置透明后会与下方的view错位~ 就是让下方VIew全屏 覆盖状态栏,解决方法


首先要在布局文件中加入下面两个属性:

android:clipToPadding="true"

android:fitsSystemWindows="true"


解释一下上面两个布局属性的意思:

android:clipToPadding 定义布局间是否有间距

android:fitsSystemWindows="true" 意思就是设置应用布局时是否考虑系统窗口布局;如果为true,将调整系统窗口布局以适应你自定义的布局。比如系统有状态栏,应用也有状态栏时。看你这个布局代码,恰恰是在定义标题栏样式,所以用到这行代码了。


===================以上是运用第三方包,可以有更多的灵活性之类的==========================




=====================以下是一种非常快捷~的方法~=======================================



代码中设置:

//透明状态栏  
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
        //透明导航栏  
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 

可以使用别的办法,主题阿之类的~ 没百度,这样状态栏就会沉浸(和下方View叠加)



布局中添加:

android:fitsSystemWindows="true"
    android:clipToPadding="true"  

将此代码加入到~ 你想状态栏改变颜色相对应的View上,比如VIew1背景色是红色,加入以后状态栏就是红色的~



布局中设置透明状态栏的方法:


引用主题

android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor"

android:theme="@android:style/Theme.Holo.Light.NoActionBar.TranslucentDecor"

android:theme="@android:style/Theme.Holo.NoActionBar.TranslucentDecor"


如果使用自定主题,只需在在values-v19 文件夹下添加以下属性

<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar" >

    <!-- API 19 theme customizations can go here. -->

    <item name="android:windowTranslucentStatus">true</item>

    <item name="android:windowTranslucentNavigation">true</item>

</style>

<span style="font-family: 'Comic Sans MS';"><span style="white-space:pre"></span>values-v19代表在API 19+的设备上,用该目录下的styles.xml代替res/values/styles.xml</span>






以下是原帖内容:




这个特性是andorid4.4支持的,最少要api19才可以使用。下面介绍一下使用的方法,非常得简单:

[java] view plain copy
  1. public class MainActivity extends Activity {  
  2.   
  3.     @Override  
  4.     protected void onCreate(Bundle savedInstanceState) {  
  5.         super.onCreate(savedInstanceState);  
  6.         setContentView(R.layout.activity_main);  
  7.   
  8.         //透明状态栏  
  9.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  10.         //透明导航栏  
  11.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
  12.   
  13.     }  
  14.   
  15.   
  16. }  


[java] view plain copy
  1. //透明状态栏  
  2. getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  3. //透明导航栏  
  4. getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  

只要加入这两行代码,就可以实现沉浸式通知栏了。效果如图:



给大家看看这个界面的布局:

[html] view plain copy
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="#ffffff"  
  6.     android:orientation="vertical"  
  7.     tools:context=".MainActivity">  
  8.   
  9.   
  10.     <TextView  
  11.   
  12.         android:layout_width="match_parent"  
  13.         android:layout_height="100dp"  
  14.         android:background="#009959" />  
  15.   
  16.   
  17.     <Button  
  18.         android:layout_width="100dp"  
  19.         android:layout_height="50dp"  
  20.         android:background="#ff669d"/>  
  21.   
  22. </LinearLayout>  

是一个垂直的流布局,但这样,其实还是有问题的,我在textView里面加一些文字,就是绿色的那一块,大家看一下效果:


大家看到了吧,文字和状态栏重叠在一起了,这肯定是不行的,此时需要添加下面的代码:


[html] view plain copy
  1. android:fitsSystemWindows="true"  
  2. android:clipToPadding="true"  

[html] view plain copy
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.       
  6.     android:fitsSystemWindows="true"  
  7.     android:clipToPadding="true"  
  8.   
  9.     android:background="#ffffff"  
  10.     android:orientation="vertical"  
  11.     tools:context=".MainActivity">  
  12.   
  13.   
  14.   
  15.     <TextView  
  16.         android:layout_width="match_parent"  
  17.         android:layout_height="100dp"  
  18.         android:background="#009959" />  
  19.   
  20.   
  21.     <Button  
  22.         android:layout_width="100dp"  
  23.         android:layout_height="50dp"  
  24.         android:background="#ff669d"/>  
  25.   
  26. </LinearLayout>  

大家看红色的那部分,加入那两行以后,界面仍然会是沉浸式的,但状态栏那部分,就不会再重叠了,像加了padding一样,如下图:


大家看图,绿色的textView和红色的一个button都被下移了,状态栏是白色的,是背景linearLayout的颜色。很明显,这也不是我们想要的,我们希望状态栏和我们放在顶部的控件是同一个颜色,同时,控件内容也不和状态栏重复,其实,只要把那两行代码放到我们顶部的控件就可以了。代码如下:


[html] view plain copy
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="#ffffff"  
  6.     android:orientation="vertical"  
  7.     tools:context=".MainActivity">  
  8.   
  9.   
  10.   
  11.     <TextView  
  12.         android:fitsSystemWindows="true"  
  13.         android:clipToPadding="true"  
  14.   
  15.         android:layout_width="match_parent"  
  16.         android:layout_height="100dp"  
  17.         android:background="#009959"  
  18.         android:text="你好,请问你有男朋友吗"/>  
  19.   
  20.   
  21.     <Button  
  22.         android:layout_width="100dp"  
  23.         android:layout_height="50dp"  
  24.         android:background="#ff669d"/>  
  25.   
  26. </LinearLayout>  
就是那两行红色的代码,放在绿色的textView上,这样,就会是下面的效果:

这就是我们想要的了。


这个方法只有在andorid4.4中才能够使用,以下的不能使用,兼容性问题解决方案(自己还没查看~)~~~



犹豫这个特性是andorid4.4支持的,最少要api19才可以使用,那么低于4.4的怎么办呢?这里我们还是通过自定义标题栏的方式解决。

首先我们来看怎么实现文章开头特产惠界面的效果。

本应用是FragmentAcitity+Framgment实现,故主界面是四个fragment组成。
MainUIAcitivy中onCreate方法:
[java] view plain copy
  1. @Override  
  2.     public void onCreate(Bundle savedInstanceState) {  
  3.         super.onCreate(savedInstanceState);  
  4.         setContentView(R.layout.activity_main);  
  5.   
  6.         //透明状态栏  
  7.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  8.             Window window = getWindow();  
  9.             // Translucent status bar  
  10.             window.setFlags(  
  11.                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,  
  12.                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  13.         }  
  14.   
  15.         // 强制更新  
  16.         UmengUpdateAgent.setDialogListener(new UmengDialogButtonListener() {  
  17.   
  18.             @Override  
  19.             public void onClick(int status) {  
  20.                 switch (status) {  
  21.                     case UpdateStatus.Update:  
  22.                         break;  
  23.                     default:  
  24.                         // close the app  
  25.                         AppToast.showShortText(MainUIActivity.this,  
  26.                                 "非常抱歉,您需要更新应用才能继续使用");  
  27.                         MainUIActivity.this.finish();  
  28.                 }  
  29.             }  
  30.         });  
  31.     }  

首页(特产惠)布局的加载如下代码,大家可以看到根据当前api是否大于4.4,加载不同的布局,归根到底就是标题栏的不同。
[java] view plain copy
  1. @Override  
  2.    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
  3.        View view = inflater.inflate(R.layout.fragment_home, container, false);  
  4.        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  5.            view = inflater.inflate(R.layout.fragment_home_v19, container, false);  
  6.        }  
  7.        return view;  
  8.    }  

fragment_home.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="@color/app_bg"  
  6.     android:orientation="vertical"  
  7.     >  
  8.   
  9.         <!--其他布局-->  
  10.   
  11.     <RelativeLayout  
  12.         android:id="@+id/index_title_bar"  
  13.         android:layout_alignParentTop="true"  
  14.         style="@style/title_bar_style_home"  
  15.         android:fitsSystemWindows="true"  
  16.         android:gravity="center"  
  17.         >  
  18.   
  19.         <TextView  
  20.             android:id="@+id/current_city_text"  
  21.             android:layout_width="wrap_content"  
  22.             android:layout_height="wrap_content"  
  23.             android:layout_alignParentLeft="true"  
  24.             android:layout_centerVertical="true"  
  25.             android:layout_marginLeft="10dp"  
  26.             android:drawableTop="@drawable/ic_location"  
  27.             android:drawablePadding="2dp"  
  28.             android:text="北京"  
  29.             android:textColor="#fff"  
  30.             android:textSize="10sp" />  
  31.   
  32.         <TextView  
  33.             android:id="@+id/tv_title"  
  34.             android:layout_centerVertical="true"  
  35.             android:layout_width="match_parent"  
  36.             android:layout_height="33dp"  
  37.             android:gravity="center_vertical"  
  38.             android:layout_weight="10"  
  39.             android:background="@drawable/shape_edit_corners_bg"  
  40.             android:hint="请输入商品名称"  
  41.             android:imeOptions="actionSearch"  
  42.             android:singleLine="true"  
  43.             android:textColor="@color/black_text"  
  44.             android:textColorHint="#ffb6b6b6"  
  45.             android:textSize="14sp"  
  46.             android:maxLength="10"  
  47.             android:paddingLeft="5dp"  
  48.             android:paddingRight="3dp"  
  49.             android:drawableLeft="@drawable/ic_search"  
  50.             android:drawableRight="@drawable/bg_btn_voice"  
  51.             android:layout_toLeftOf="@+id/image_right"  
  52.             android:layout_toRightOf="@+id/current_city_text"  
  53.             android:layout_marginLeft="10dp"  
  54.             android:layout_marginRight="10dp"/>  
  55.   
  56.         <TextView  
  57.             android:id="@+id/image_right"  
  58.             android:layout_width="wrap_content"  
  59.             android:layout_height="wrap_content"  
  60.             android:layout_alignParentRight="true"  
  61.             android:layout_centerVertical="true"  
  62.             android:layout_marginRight="10dp"  
  63.             android:drawableTop="@drawable/ic_category"  
  64.             android:drawablePadding="2dp"  
  65.             android:text="分类"  
  66.             android:textColor="#fff"  
  67.             android:textSize="10sp" />  
  68.   
  69.     </RelativeLayout>  
  70. </RelativeLayout>  

fragment_home_v19.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="@color/app_bg"  
  6.     android:orientation="vertical"  
  7.     >  
  8.   
  9.         <!-- 其他布局 -->  
  10.   
  11.     <RelativeLayout  
  12.         android:id="@+id/index_title_bar"  
  13.         android:layout_alignParentTop="true"  
  14.         style="@style/title_bar_style_home_v19"  
  15.         android:fitsSystemWindows="true"  
  16.         android:gravity="center"  
  17.         android:paddingTop="@dimen/title_bar_padding_top"  
  18.         >  
  19.   
  20.         <TextView  
  21.             android:id="@+id/current_city_text"  
  22.             android:layout_width="wrap_content"  
  23.             android:layout_height="wrap_content"  
  24.             android:layout_alignParentLeft="true"  
  25.             android:layout_centerVertical="true"  
  26.             android:layout_marginLeft="10dp"  
  27.             android:drawableTop="@drawable/ic_location"  
  28.             android:drawablePadding="2dp"  
  29.             android:text="北京"  
  30.             android:textColor="#fff"  
  31.             android:textSize="10sp" />  
  32.   
  33.         <TextView  
  34.             android:id="@+id/tv_title"  
  35.             android:layout_centerVertical="true"  
  36.             android:layout_width="match_parent"  
  37.             android:layout_height="33dp"  
  38.             android:gravity="center_vertical"  
  39.             android:layout_weight="10"  
  40.             android:background="@drawable/shape_edit_corners_bg"  
  41.             android:hint="请输入商品名称"  
  42.             android:imeOptions="actionSearch"  
  43.             android:singleLine="true"  
  44.             android:textColor="@color/black_text"  
  45.             android:textColorHint="#ffb6b6b6"  
  46.             android:textSize="14sp"  
  47.             android:maxLength="10"  
  48.             android:paddingLeft="5dp"  
  49.             android:paddingRight="3dp"  
  50.             android:drawableLeft="@drawable/ic_search"  
  51.             android:drawableRight="@drawable/bg_btn_voice"  
  52.             android:layout_toLeftOf="@+id/image_right"  
  53.             android:layout_toRightOf="@+id/current_city_text"  
  54.             android:layout_marginLeft="10dp"  
  55.             android:layout_marginRight="10dp"/>  
  56.   
  57.         <TextView  
  58.             android:id="@+id/image_right"  
  59.             android:layout_width="wrap_content"  
  60.             android:layout_height="wrap_content"  
  61.             android:layout_alignParentRight="true"  
  62.             android:layout_centerVertical="true"  
  63.             android:layout_marginRight="10dp"  
  64.             android:drawableTop="@drawable/ic_category"  
  65.             android:drawablePadding="2dp"  
  66.             android:text="分类"  
  67.             android:textColor="#fff"  
  68.             android:textSize="10sp" />  
  69.   
  70.     </RelativeLayout>  
  71. </RelativeLayout>  

style.xml
[html] view plain copy
  1. <style name="title_bar_style_home"><!-- 首页用 -->  
  2.         <item name="android:background">#ffc6003b</item>  
  3.         <item name="android:paddingLeft">0.0dip</item>  
  4.         <item name="android:paddingRight">0.0dip</item>  
  5.         <item name="android:layout_width">fill_parent</item>  
  6.         <item name="android:layout_height">48dp</item>  
  7.     </style>  
  8.     <style name="title_bar_style_home_v19"><!-- 首页用v19 -->  
  9.         <item name="android:background">#ffc6003b</item>  
  10.         <item name="android:paddingLeft">0.0dip</item>  
  11.         <item name="android:paddingRight">0.0dip</item>  
  12.         <item name="android:layout_width">fill_parent</item>  
  13.         <item name="android:layout_height">65dp</item>  
  14.     </style>  
values/dimens.xml
<dimen name="title_bar_padding_top">0dp</dimen>
values-v19/dimens.xml
<dimen name="title_bar_padding_top">20dp</dimen>

首页(特产惠)的关键代码就这么多,下面我们来重点看第二个fragment(生活+)。

跟首页不同的是,生活+界面的标题栏是白色的,如果实现侵色,状态栏也是白色的,这样状态栏的白色字就看不见了,下面给出解决方法。

解决的办法还是自定义标题栏。

原理:自定义标题栏(包含状态栏),背景为黑色,也就是状态栏的颜色。高度为68dp,然后设置paddingTop=20dp,这个20dp就是状态栏的高度。剩下的48dp就是我们真正的标题栏。

首先还是根据当前api是否大于4.4,加载不同的布局,归根到底就是状态栏的不同。
[java] view plain copy
  1. @Override  
  2.     public View onCreateView(LayoutInflater inflater, ViewGroup container,  
  3.             Bundle savedInstanceState) {  
  4.         View view = inflater.inflate(R.layout.fragment_life, container, false);  
  5.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  6.             view = inflater.inflate(R.layout.fragment_life_v19, container, false);  
  7.         }  
  8.           
  9.         return view;  
  10.     }  

fragment_life.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:id="@+id/root_layout"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="match_parent"  
  6.     android:orientation="vertical">  
  7.   
  8.     <include layout="@layout/title_bar_main" />  
  9.   
  10.     <!-- 其他布局 -->  
  11. </LinearLayout>  


title_bar_main.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:id="@+id/main_title_bar"  
  4.     style="@style/title_bar_style_main"  
  5.     android:fitsSystemWindows="true"  
  6.     >  
  7.   
  8.     <RelativeLayout  
  9.         android:layout_width="match_parent"  
  10.         android:layout_height="match_parent"  
  11.         android:background="#FFFEFEFE">  
  12.   
  13.         <TextView  
  14.             android:id="@+id/title_text"  
  15.             style="@style/title_text_style"  
  16.             android:layout_width="wrap_content"  
  17.             android:layout_height="wrap_content"  
  18.             android:layout_centerInParent="true"  
  19.             android:ellipsize="end"  
  20.             android:singleLine="true" />  
  21.   
  22.         <ImageView  
  23.             android:id="@+id/right_img"  
  24.             android:layout_width="wrap_content"  
  25.             android:layout_height="wrap_content"  
  26.             android:layout_alignParentRight="true"  
  27.             android:layout_centerVertical="true"  
  28.             android:contentDescription="@null"  
  29.             android:paddingLeft="15dp"  
  30.             android:paddingRight="15dp"  
  31.             android:src="@drawable/ic_notice"  
  32.             android:visibility="gone"/>  
  33.   
  34.   
  35.     </RelativeLayout>  
  36. </LinearLayout>  

fragment_life_v19.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:id="@+id/root_layout"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="match_parent"  
  6.     android:orientation="vertical">  
  7.   
  8.     <include layout="@layout/title_bar_main_v19" />  
  9.   
  10.     <!-- 其他布局 -->  
  11.   
  12.       
  13.   
  14. </LinearLayout>  

title_bar_main_v19.xml
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:id="@+id/main_title_bar"  
  4.     style="@style/title_bar_style_main_19"  
  5.     android:fitsSystemWindows="true"  
  6.     android:paddingTop="@dimen/title_bar_padding_top">  
  7.   
  8.     <RelativeLayout  
  9.         android:layout_width="match_parent"  
  10.         android:layout_height="match_parent"  
  11.         android:background="#FFFEFEFE">  
  12.   
  13.         <TextView  
  14.             android:id="@+id/title_text"  
  15.             style="@style/title_text_style"  
  16.             android:layout_width="wrap_content"  
  17.             android:layout_height="wrap_content"  
  18.             android:layout_centerInParent="true"  
  19.             android:ellipsize="end"  
  20.             android:singleLine="true" />  
  21.   
  22.         <ImageView  
  23.             android:id="@+id/right_img"  
  24.             android:layout_width="wrap_content"  
  25.             android:layout_height="wrap_content"  
  26.             android:layout_alignParentRight="true"  
  27.             android:layout_centerVertical="true"  
  28.             android:contentDescription="@null"  
  29.             android:paddingLeft="15dp"  
  30.             android:paddingRight="15dp"  
  31.             android:src="@drawable/ic_notice"  
  32.             android:visibility="gone"/>  
  33.   
  34.   
  35.     </RelativeLayout>  
  36. </LinearLayout>  

style.xml
[html] view plain copy
  1. <style name="title_bar_style_main">  
  2.         <item name="android:background">#FFFEFEFE</item>  
  3.         <item name="android:paddingLeft">0.0dip</item>  
  4.         <item name="android:paddingRight">0.0dip</item>  
  5.         <item name="android:layout_width">fill_parent</item>  
  6.         <item name="android:layout_height">48dp</item>  
  7.         <item name="android:gravity">center_vertical</item>  
  8.     </style>  
  9.     <style name="title_bar_style_main_19">  
  10.         <item name="android:background">@android:color/black</item>  
  11.         <item name="android:paddingLeft">0.0dip</item>  
  12.         <item name="android:paddingRight">0.0dip</item>  
  13.         <item name="android:layout_width">fill_parent</item>  
  14.         <item name="android:layout_height">68dp</item>  
  15.         <item name="android:gravity">center_vertical</item>  
  16.     </style>  











0 0
原创粉丝点击