王立平--自己定义TitleBar
效果:
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的更多相关文章
- 王立平--TableLayout
效果: <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android= ...
- 王立平--android事件监听的3种方式
第一种通常在activity组件的oncreate事件中直接定义,直接动作. 这样的方式每一个控件都定义一次.通常不方便. Button btn = (Button) findViewById(R.i ...
- 王立平--PopupWindow
MainActivity.java <span style="font-size:14px;">package com.main; import android.app ...
- 王立平--string.Empty
String.Empty 字段 .NET Framework 类库 表示空字符串.此字段为仅仅读.命名空间:System 程序集:mscorlib(在 mscorlib.dll 中) protecte ...
- 王立平--include在Android中的应用
一个布局中包括还有一个布局 1.在layout下定义activity_other.xml布局 2.代码中的包括例如以下: <LinearLayout xmlns:android="ht ...
- 王立平--java se的简单项目创建以及具体解释
创建项目的简单步骤: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzQyNTUyNw==/font/5a6L5L2T/fontsize/400/ ...
- 王立平--RemoteView
RemoteView它将在两个地方被使用:一个是在AppWidget,另外一个是在Notification. RemoteView是用来描写叙述一个垮进程显示的view 1.AppWidget---R ...
- 王立平--EditPlus激活码
注冊名:Free User 注冊码:6AC8D-784D8-DDZ95-B8W3A-45TFA
- 王立平-Android中对图像进行Base64编码
// ------------------base64-------------------// public String bitmaptoString(Bitmap bitmap) { // 将B ...
随机推荐
- Chisel Tutorial(一)——Chisel介绍
Chisel是由伯克利大学公布的一种开源硬件构建语言,建立在Scala语言之上,是Scala特定领域语言的一个应用,具有高度參数化的生成器(highly parameterized generator ...
- 遗传奥秘的伟大揭秘者:J.Watson
J.Watson的近照: 人们公认,揭秘生命体的遗传奥秘(DNA)是二十世纪最伟大的科技成果之中的一个,或许就是人类最伟大的科技进步(而不是"之中的一个"). 上世纪是人类做出伟大 ...
- h5-列表
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAX4AAAInCAIAAAAQ0aUJAAAgAElEQVR4nOy9eVxb153wnZk+z/t53n ...
- notepad++ 查找引用(Find Reference)(适用于c c++及各类脚本比如lua、python等)
在程序开发过程中,程序员经常用到的一个功能就是查找引用(Find Reference),Visual Studio里面的对应功能是“查找所有引用”(Find All References). 我在使用 ...
- 浅谈for循环
for循环 <script> /* ** (1) 是执行代码块之前 ** (2) 运行代码块的条件 ** (3) 需要执行的代码块 ** (4) 代码块执行后执行 ** 执行顺序是(1)( ...
- 20个非常有用的Java程序片段--转
原文地址:http://geek.csdn.net/news/detail/236591 下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = ...
- swift使用查阅资料备份2
Swift3.0朝圣之路-Then协议库-绝妙的初始化方式 https://www.jianshu.com/p/6cc1e21df6ac DisposeBag http://southpeak.git ...
- scrollBot滚动条美化,niceScroll有滚动条错位得问题
http://www.htmleaf.com/Demo/201706204585.html
- 计算机网络Intro
1. 计算机网络体系结构 1.1 简介 定义 计算机网络的各层 + 其协议的集合 作用 定义该计算机网络的所能完成的功能 1.2 结构介绍 计算机网络体系结构分为3种:OSI体系结构.TCP / IP ...
- CSS Grid(CSS网格)
Grid被设计来做一些Flexbox不能做的事情,所以不是被设计来取代Flexbox的. flexbox 一维的 Grid 二维的 总结: Grid Items作用在Grid Container的直 ...