效果:

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();

    }

王立平--自己定义TitleBar的更多相关文章

  1. 王立平--TableLayout

    效果: <?xml version="1.0" encoding="utf-8"?>  <TableLayout xmlns:android= ...

  2. 王立平--android事件监听的3种方式

    第一种通常在activity组件的oncreate事件中直接定义,直接动作. 这样的方式每一个控件都定义一次.通常不方便. Button btn = (Button) findViewById(R.i ...

  3. 王立平--PopupWindow

    MainActivity.java <span style="font-size:14px;">package com.main; import android.app ...

  4. 王立平--string.Empty

    String.Empty 字段 .NET Framework 类库 表示空字符串.此字段为仅仅读.命名空间:System 程序集:mscorlib(在 mscorlib.dll 中) protecte ...

  5. 王立平--include在Android中的应用

    一个布局中包括还有一个布局 1.在layout下定义activity_other.xml布局 2.代码中的包括例如以下: <LinearLayout xmlns:android="ht ...

  6. 王立平--java se的简单项目创建以及具体解释

    创建项目的简单步骤: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzQyNTUyNw==/font/5a6L5L2T/fontsize/400/ ...

  7. 王立平--RemoteView

    RemoteView它将在两个地方被使用:一个是在AppWidget,另外一个是在Notification. RemoteView是用来描写叙述一个垮进程显示的view 1.AppWidget---R ...

  8. 王立平--EditPlus激活码

    注冊名:Free User 注冊码:6AC8D-784D8-DDZ95-B8W3A-45TFA

  9. 王立平-Android中对图像进行Base64编码

    // ------------------base64-------------------// public String bitmaptoString(Bitmap bitmap) { // 将B ...

随机推荐

  1. poj - 1159 - Palindrome(滚动数组dp)

    题意:一个长为N的字符串( 3 <= N <= 5000).问最少插入多少个字符使其变成回文串. 题目链接:http://poj.org/problem?id=1159 -->> ...

  2. [jzoj 6093] [GDOI2019模拟2019.3.30] 星辰大海 解题报告 (半平面交)

    题目链接: https://jzoj.net/senior/#contest/show/2686/2 题目: 题解: 说实话这题调试差不多花了我十小时,不过总算借着这道题大概了解了计算几何的基础知识 ...

  3. ROS-单目摄像头标定

    前言:由于摄像图内部与外部的原因,生成的图像往往会发生畸变,为了避免数据源造成的误差,需要针对摄像头的参数进行标定. ros官方提供了camera_calibration软件包进行摄像头标定. 一.安 ...

  4. pyCrypto python 3.5--转

    原文地址:https://gxnotes.com/article/198426.html 问题描述 我发现一些PyCrypto安装程序为Python 3.3和3.4,但没有任何Python 3.5. ...

  5. C语言中以文本方式读写文件时换行符转换的注意事项

    我们知道在UNIX下是没有回车符(\r)的,只有换行符(\n),而C语言诞生于UNIX(Linux即面向开源的UNIX,Mac OS也是UNIX发展而来的,而Windows是从MS-DOS发展而来,与 ...

  6. Array.prototype.slice.call(arguments) 通俗法理解

    Array.prototype.slice.call(arguments,num) 能将具有length属性的对象转成数组.   slice 从字面上的意思可以理解为截取数组的一部分. call 从字 ...

  7. Oracle学习笔记——常用函数总结

    在平时写PL/SQL的时候,经常要用到很多系统自带的函数,而这些函数用起来非常好用,但是每次用完以后,就又忘到脑后了,为了加深自己的映象,以及对这些函数做一个全面的总结,就有了今天这篇文章. 首先这就 ...

  8. C#数组大小分析(附测试过程中想起的debug和release区别)

    C#数组的理论最大长度到底是多少呢?曾经一度问过度娘,谷歌,貌似都没有得出一个比较准确的答案,无外乎是什么Int32的最大值啊什么的,今天终于决定写个软件来自己测试一下,在几台不同的电脑里面实际测试看 ...

  9. 人人都是产品经理?关于PM你不知道的还有很多

    产品经理的职称最早出现在P&G宝洁公司,因效果非常显著,许多企业纷纷仿而效尤.硅谷知名的产品管理大师Marty Cagan在<Inspired: How To Create Produc ...

  10. Unity 烘焙的2种方式

    游戏场景通常有许多光源,使用实时渲染会非常消耗性能,解决办法是烘焙,烘焙有2种方式. 1, 在3dmax等模型制作软件中对场景进行烘焙.将烘焙好的模型以及贴图导入到unity3d. 相对复杂但效果好 ...