android自定义标题的相关问题
2014-10-09 21:08
295 查看
一.在完成下面几步之后
1. 创建自定义标题栏的xml文件,可以给标题栏加背景(引用图片或者在drawable文件下通过xml文件生成);
2.在activity中通过requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);// 声明使用自定义标题
3.setContentView(R.layout.activity_login);//加载主界面
4. getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
// 添加自定义布局
如果出现you cannot combine custom titles with other title features这个运行时异常,请检查values下的styles.xml文件中
是否有
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
</style>
很多项目初建时<item name="android:windowActionBar">false</item> 是没有的。
二:自定义标题没有铺满宽度,这个已经有很多大手解释并给出了操作步骤,此处不做说明
三:自定义标题的高度问题,发现即使在styles.xml中配置了
<item name="android:windowTitleSize">100dp</item>
如果自定义的标题栏xml只有文本,如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/content" />
</LinearLayout>
那么高度还是一点点高,实验发现是跟TextView的高度一致的。
如果想要高度改变,可以将LinearLayout 的高度设置成100dp,跟<item name="android:windowTitleSize">100dp</item>的值保持一样即可。
1. 创建自定义标题栏的xml文件,可以给标题栏加背景(引用图片或者在drawable文件下通过xml文件生成);
2.在activity中通过requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);// 声明使用自定义标题
3.setContentView(R.layout.activity_login);//加载主界面
4. getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
// 添加自定义布局
如果出现you cannot combine custom titles with other title features这个运行时异常,请检查values下的styles.xml文件中
是否有
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
</style>
很多项目初建时<item name="android:windowActionBar">false</item> 是没有的。
二:自定义标题没有铺满宽度,这个已经有很多大手解释并给出了操作步骤,此处不做说明
三:自定义标题的高度问题,发现即使在styles.xml中配置了
<item name="android:windowTitleSize">100dp</item>
如果自定义的标题栏xml只有文本,如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/content" />
</LinearLayout>
那么高度还是一点点高,实验发现是跟TextView的高度一致的。
如果想要高度改变,可以将LinearLayout 的高度设置成100dp,跟<item name="android:windowTitleSize">100dp</item>的值保持一样即可。
相关文章推荐
- Android自定义View研究(六)--View中的原点坐标相关问题
- android 自定义动态加载数据的折线图及相关问题解析
- 解决android自定义标题充满的问题
- Android自定义View研究(六)--View中的原点坐标相关问题
- Android自定义View研究(六)--View中的原点坐标相关问题
- Android有关自定义标题的问题 You cannot combine custom titles with other title features
- Android自定义View研究(六)--View中的原点坐标相关问题
- Android自定义View研究(六)--View中的原点坐标相关问题
- Android自定义View研究(六)--View中的原点坐标相关问题
- Android 完美解决自定义preference与ActivityGroup UI更新的问题 推荐
- 解决android自定义标题栏充满的问题
- android开发过程中遇到的一些问题(包括自定义ProgressBar, Intent, Animation, ListView, RadioButton)
- android 自定义权限问题
- 解决android自定义标题栏充满的问题
- css 标题 一行图片 两行文字 以及相关问题处理
- Android TextView标点符号换行问题(顺便学习Android自定义View)
- ASP.NET web的自定义用户控件以及相关问题
- Android中自定义ListView无法响应OnItemClickListener中的onItemClick方法问题解决方案<转>
- Android ListView 自定义背景后 滚动时的背景变黑问题
- android相关问题、网摘集锦(持续更新中...)