Android如何设置标题栏的高度
新建一个styles.xml
<?xmlversion="1.0" encoding="utf-8"?> <resources> <style name="titlebarstyle"parent="Android:Theme"> <item name="Android:windowTitleSize">38dip</item> </style> </resources>
上面<item name="Android:windowTitleSize">39dip</item>这一句,就是用来设定Titlebar的高度的。
我们需要修改AndroidManifest.xml中,相应Activity的属性。代码如下:
<?xmlversion="1.0" encoding="utf-8"?> <manifestxmlns:Android="http://schemas.android.com/apk/res/android" package="com.pat.customizetitlebar" Android:versionCode="1" Android:versionName="1.0"> <applicationAndroid:icon="@drawable/icon"android:label="@string/app_name"> <activity Android:name=".CustomizeTitlebar" Android:label="@string/app_name" Android:theme="@style/titlebarstyle"> <intent-filter> <action Android:name="android.intent.action.MAIN"/> <categoryAndroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> <uses-sdk Android:minSdkVersion="8"/> </manifest>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步