zoukankan      html  css  js  c++  java
  • 如何定制Activity的标题栏

     requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

            setContentView(R.layout.main);

            //自定义标题栏
            mWindow = getWindow();
            mWindow.setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.titlebar);

    titlebar.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
    >
            <TextView
                    android:text="@string/app_name"
                    android:textColor="#000"
                    android:paddingRight="3.0dip"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"/>
            <TextView
                    android:text="@string/battery_text"
                    android:textColor="#000"
                    android:paddingRight="3.0dip"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"/>
            <TextView
                    android:id="@+id/battery_text"
                    android:textColor="#00f"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"/>
    </LinearLayout>

     上述的话只是适合android4.0一下的版本,如果需要针对android4.0以上的版本的话需要我们使用自己的样式

      <style name="TitleBackgroundColor">
             <item name="android:background">@color/background_color</item>
         </style>
         
         <style name="titlestyle" parent="android:Theme" >
             <item name="android:windowTitleSize">40dip</item>  
             <item name="android:windowTitleBackgroundStyle">@style/TitleBackgroundColor</item>
         </style> 
    然后在配置文件中加上,OK
    <activity android:name="com.ygl.ui.LoginActivity" android:theme="@style/titlestyle" ></activity>
  • 相关阅读:
    如何修改以前登录过的共享文件夹的用户名和密码以及查看或删除浏览器里保存的密码
    python-----获取ip的两种方法
    SSO(singlesignon)单点登录
    ajax
    mybatis14--注解的配置
    mybatis13--2级缓存
    mybatis12--一级缓存
    mybatis11--多对多关联查询
    mybatis10--自连接多对一查询
    mybatis09--自连接一对多查询
  • 原文地址:https://www.cnblogs.com/DASOU/p/4261038.html
Copyright © 2011-2022 走看看