如何定制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>
如何定制Activity的标题栏的更多相关文章
- Android 自定义Activity的标题栏(Titlebar)
缺省的情况下,通常见到Activity的标题栏(Titlebar)是这样的(红色框内): HandleContacts是Activity的标题.有时候,我们希望能改变一下这样单调的状况.比如,要在标题 ...
- 自定义 Activity 的 标题栏 TitleBar
自定义 Activity 的 标题栏 TitleBar 1. 修改标题栏的高度,背景 编辑styles.xml,添加: <?xmlversion="1.0" encoding ...
- activity去标题栏操作&保留高版本主题
方式一:每个类都需要去添加此代码 在setContentView(R.layout.activity_splash); 前设置以下代码 requestWindowFeature(Window.FEAT ...
- Android Activity 去掉标题栏及全屏显示
默认生成的活动(Activity)界面中包含标题栏,并带有状态栏.有时不需要这两个控件. 1.去掉标题栏 (三种方法) a:在setContentView()方法前 添加:requestWindowF ...
- 两种方法一句代码隐藏Activity的标题栏
把Activity的标题栏隐藏有两种方法.一种是在在Activity里面设置javacode.还有一种是在项目的清单文件AndroidManifest.xml中设置模版样式. 一.在Activity中 ...
- 继承AppCompatActivity的Activity隐藏标题栏
继承了AppCompatActivity的Activity无法通过调用requestWindowFeature(Window.FEATURE_NO_TITLE)来隐藏标题栏. public class ...
- 去掉安卓中activity的标题栏
去掉所有Activity界面的标题栏 修改AndroidManifest.xml 在application 标签中添加android:theme="@android:style/Theme. ...
- 设置隐藏activity的标题栏
values->styles.xml中设置:stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBa ...
- Android——Activity去除标题栏和状态栏
一.在代码中设置 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //去 ...
随机推荐
- js中的tostring()方法
http://blog.sina.com.cn/s/blog_85c1dc100101bxgg.html js中的tostring()方法 (2013-11-12 11:07:43) 转载▼ 标签: ...
- 又是一天String
(1) Length of Last Word 解题思路:使用length记录最后一个单词的长度.从最后一个字符开始,如果是空字符,length不变.如果不是空字符,length++,直到再次遇到空字 ...
- JSON文本转换为JSONArray 转换为 List<Object>
package com.beijxing.TestMain; import java.io.File; import java.io.IOException; import java.util.Arr ...
- 使用Goertzel算法识别DTMF信号
Goertzel算法 Goertzel算法由Gerald Goertzel在1958年提出,用于数字信号处理,是属于离散傅里叶变换的范畴,目的是从给定的采样中求出某一特定频率信号的能量,用于有效性的评 ...
- php调用阿里大鱼 接口curl
function http_request($url, $data = null, $header = null, $method = 'GET') { //如果是Get传参,拼接字符串 if ($m ...
- winform空间批量控制
第一版: private void RefreshControl(PanelEx panel, bool enabled, bool isClear) { ; i < panel.Control ...
- Js制作的文字游戏
自己制作的文字游戏.(: <!DOCTYPE html><html lang="en"><head> <meta charset=& ...
- @Repository、@Service、@Controller 和 @Component
转载:http://blog.csdn.net/ye1992/article/details/19971467 spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的开发.@ ...
- mysql中的where和having子句的区别
mysql中的where和having子句的区别 having的用法 having字句可以让我们筛选成组后的各种数据,where字句在聚合前先筛选记录,也就是说作用在group by和having字句 ...
- Ceph剖析:Leader选举
作者:吴香伟 发表于 2014/09/11 版权声明:可以任意转载,转载时务必以超链接形式标明文章原始出处和作者信息以及版权声明 Paxos算法存在活锁问题.从节点中选出Leader,然后将所有对数据 ...