效果:

1.自己定义titleBar的布局。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent" > 

    <TextView

        android:id="@+id/tv_SongsCount"

        android:layout_width="70dp"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_centerVertical="true"

        android:layout_marginLeft="10dp"

        android:singleLine="true"

        android:text="2222"

        android:textColor="#FFFFF0"

        android:textStyle="bold" />





    <TextView

        android:id="@+id/tv_Title"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_centerVertical="true"

        android:gravity="center"

        android:text="hahahahaha"

        android:textColor="#3a3a3a"

        android:textSize="20sp" />





    <ImageButton

        android:id="@+id/imgBtn_ToPlay"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentRight="true"

        android:layout_centerVertical="true"

        android:layout_marginRight="10dp"

        android:background="@null"

        android:contentDescription="ppppme"

        android:src="@drawable/btn" />





</RelativeLayout>

2.在.java中载入布局。

private void initTitleBar() {

  getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,

  R.layout.titlebar);

  }

3.调用initTitleBar

@Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

//声明使用自己定义标题

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

setContentView(R.layout.activity_main);

        initTitleBar();

    }

最新文章

  1. 以冒泡排序为例--malloc/free 重定向stdin stdout
  2. Jetty使用教程(四:21-22)—Jetty开发指南
  3. 肯爹的 StringUtils.isNumeric(String str)
  4. C语言中的++和--
  5. CLRS:max_heap and min_heap operation (pseudocode)
  6. for循环绑定事件,闭包思想!
  7. AngularJS数据建模(转载)
  8. 设计理念 : popup login 在前后台
  9. 命令行创建Maven项目卡住以及出错解决办法。
  10. python语言基础语法笔记&lt;note2--面向对象编程&gt;
  11. .net core下用HttpClient和asp.net core实现https的双向认证
  12. idea的一般使用和初始配置
  13. IDEA 启动项目前的配置--或过程遇到的问题
  14. 分治法——快速排序(quicksort)
  15. LAB4
  16. iOS objc_msgSend 报错解决方案
  17. poj 1879 Truck History
  18. Azure Linux 虚拟机常见导致无法远程的操作
  19. php独特的语法
  20. atitit。获取表格的字段注释metadata的原理以及AND 字段表格描述文档方案

热门文章

  1. ANT公布SVN WEB项目到TOMCAT以及利用post-commit自己主动提交编译更新
  2. (转)c++ typedef 函数指针详细说明
  3. Java-SpringCloud:目录
  4. 29.QT主窗口加widget
  5. tomcat开启https服务
  6. layer-list
  7. javaweb 之 文件上传与下载
  8. sql调优《二》
  9. c/c++连接mysql数据库设置及乱码问题(vs2013连接mysql数据库,使用Mysql API操作数据库)
  10. flex-2