自定义标题栏
来源:互联网 发布:淘宝无门槛红包设置 编辑:程序博客网 时间:2024/06/01 07:12
1.标题栏需创建一个新的layout(title)
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageView android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_input_get" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dp" android:text="画板" android:paddingRight="50dp" android:layout_gravity="center_vertical" /> </LinearLayout>
2.在activity中调用
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.activity_main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
这样就可以了,但可能会触发异常:
Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
2.,在 app的style中增加下面一个标识
<item name="android:windowActionBar">false</item>
来去掉action bar. 但是这个方法有个限制 就是这个标识必须是api level 11以上的。
具体如下:
<style name="AppTheme" parent="AppTheme"><item name="android:windowActionBar">false</item> </style>
3.修改一下Andriodmainifest
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name="com.example.handdraw.HandDraw" android:theme="@style/AppTheme" >
应该就可以了。
阅读全文
0 0
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义 标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 自定义标题栏
- 常用eharts图表展示方法(内附5个常用样例)
- redis增大查询速度(项目中实际应用举例)
- python学习(四)之条件+循环
- Android内存泄漏和内存调优
- JavaScript闭包
- 自定义标题栏
- 记录每次更新到本地git仓库
- QT图形框架
- JNI与C++数据类型传递示例(包括ArrayList对象、ArrayList嵌套返回)
- Matlab基础
- shawn的博客开通啦
- react 子元素改变父元素属性
- JavaScript Canvas画布
- PAT 1033. To Fill or Not to Fill (25) 贪心