Android在顶部标题栏添加按钮
来源:互联网 发布:linux ip命令查看ip 编辑:程序博客网 时间:2024/06/06 20:33
1.在标题栏添加按钮
首先标题栏也有自己单独的xml 比如这里叫title.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageButton android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:src="@drawable/prv" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="欢迎界面" /> <ImageButton android:id="@+id/next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:layout_centerInParent="true" android:layout_alignParentRight="true" android:src="@drawable/next" /> </RelativeLayout>
//主要定义了一个返回按钮、一个标题栏,一个下一页按钮
然后在MainActivity的onCreate方法中:
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.welcome);getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);}
1.在标题栏添加按钮
首先标题栏也有自己单独的xml 比如这里叫title.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="@drawable/prv" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="欢迎界面" />
<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:src="@drawable/next" />
</RelativeLayout>
//主要定义了一个返回按钮、一个标题栏,一个下一页按钮
然后在MainActivity的onCreate方法中:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.welcome);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
}
0 0
- Android在顶部标题栏添加按钮
- 在网页中添加 “返回顶部”按钮
- Android标题栏最右边添加按钮
- android标题栏中添加返回按钮
- android标题栏中添加返回按钮
- android标题栏中添加返回按钮
- android去掉顶部标题栏
- android去掉顶部标题栏
- [Android] 自定义顶部标题栏
- android 隐藏顶部标题栏
- Delphi组件开发-在窗体标题栏添加按钮
- android 顶部标题栏ActionBar详解
- Android 顶部标题栏ActionBar详解
- Android 实现一个顶部标题栏
- Android如何去掉顶部标题栏
- android实现自定义顶部标题栏
- android 在标题栏中添加控件
- Android标题栏上添加多个Menu按钮
- android View 详解
- 初识EventBus
- 深入了解mysql
- asp.net发布到IIS后提示ORA-12154:TNS:无法解析指定的连接标识符
- AndroidStudio快捷键Debugging
- Android在顶部标题栏添加按钮
- GestureDetector手势检测笔记
- Unity3D爬坑手记——Prefab篇2
- Eclipse快捷键大全(转载)
- BOW模型在ANN框架下的解释
- 35、Search Insert Position
- thinkphp 获取ip定位坐标
- (1)sensor调试过程中HAL层数据不能传输到app
- 编译安装Mysql 5.5.x