修改标题栏的高度
16lz
2021-01-23
通过源码可以发现:在一般情况下,我们用的Screen style的是:
Screen_custom_title.xml 文件
通过以上文档我们可知,title_container(标题栏)的高度由attr--windowTitleSize决定。所以改变windowTitleSize 可以改变高度。如下代码:
Screen_custom_title.xml 文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:fitsSystemWindows="true"> <FrameLayout android:id="@android:id/title_container" android:layout_width="match_parent" android:layout_height="?android:attr/windowTitleSize" style="?android:attr/windowTitleBackgroundStyle"> </FrameLayout> <FrameLayout android:id="@android:id/content" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:foregroundGravity="fill_horizontal|top" android:foreground="?android:attr/windowContentOverlay" /></LinearLayout>
通过以上文档我们可知,title_container(标题栏)的高度由attr--windowTitleSize决定。所以改变windowTitleSize 可以改变高度。如下代码:
<?xml version="1.0" encoding="utf-8"?><resources xmlns:android="http://schemas.android.com/apk/res/android"><style name="CustomWindowTitleBackground"> <item name="android:background">#565656</item></style><style name="test" parent="android:Theme"> <item name="android:windowTitleSize">50dp</item> //改变标题栏的高度 <item name="android:textSize">10dp</item> //改变文件大小 <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item></style></resources>
<application android:icon="@drawable/icon" android:label="@string/app_name" > <activity android:name=".TitleButton" android:label="@string/app_name" android:theme ="@style/test">android:theme ="@style/test" 改变了主题,这样因为test中用到了<item name="android:textSize">10dp</item> 所以默认所有的文字都是这么大小,除非在相应View中,textSize 重新被修改,或者所在Activity的主题中重新设定此值。
更多相关文章
- android 主题
- 样式和主题-style&them
- android的两个设置标题主题属性
- android 沉浸式主题记录
- 如何使android应用程序使用当前的主题样式
- android动画源码合集、动态主题框架、社交app源码等
- Android Theme主题继承(SDK下主题和v7包下主题)
- android listview的高度
- 使用XML实现BBS(主题列表篇)的详情介绍