getWindow().setFeatureInit最好在setContentView之后
第二步,就是写好自己的布局文件,实现标题栏的自定义。
不过我们会遇到一些问题,就是标题栏的高度不能自定义~下面就是解决办法~
下面,我们看一下android title标题栏 在源码 framework中的XML文件
screen_custom_title.xml
<LinearLayout 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>
screen_title.xml
<LinearLayout android:orientation=“vertical” android:fitsSystemWindows=“true”>
-
−
-
<FrameLayout android:layout_width=“match_parent”
-
android:layout_height=“?android:attr/windowTitleSize”
-
style=“?android:attr/windowTitleBackgroundStyle”>
-
<TextView android:id=“@android:id/title”
-
style=“?android:attr/windowTitleStyle”
-
android:background=“@null”
-
android:fadingEdge=“horizontal”
-
android:gravity=“center_vertical”
-
android:layout_width=“match_parent”
-
android:layout_height=“match_parent”/>
-
</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>
既然是自定义标题,那我们就看screen_custom_title.xml,里面有一个title_container和一个content,组合成了标题栏,我们自定义标题所给出的view,都被content作为子view了,影响不了那个title_container和content,所以,任你怎么弄,它该留白的还是留白,你没招。
看title_container有个style是这样的:
style=“?android:attr/windowTitleBackgroundStyle”
content的foreground是这样的android:foreground=“?android:attr/windowContentOverlay”
我们可以自己写一个style
<resources xmlns:android=“http://schemas.android.com/apk/res/android”>
作者2013年从java开发,转做Android开发,在小厂待过,也去过华为,OPPO等大厂待过,18年四月份进了阿里一直到现在。
参与过不少面试,也当面试官 面试过很多人。深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长,而且极易碰到天花板技术停滞不前!
我整理了一份阿里P7级别的最系统的Android开发主流技术,特别适合有3-5年以上经验的小伙伴深入学习提升。
主要包括阿里,以及字节跳动,腾讯,华为,小米,等一线互联网公司主流架构技术。如果你想深入系统学习Android开发,成为一名合格的高级工程师,可以收藏一下这些Android进阶技术选型
我搜集整理过这几年阿里,以及腾讯,字节跳动,华为,小米等公司的面试题,把面试的要求和技术点梳理成一份大而全的“ Android架构师”面试 Xmind(实际上比预期多花了不少精力),包含知识脉络 + 分支细节。
Java语言与原理;
大厂,小厂。Android面试先看你熟不熟悉Java语言
高级UI与自定义view;
自定义view,Android开发的基本功。
性能调优;
数据结构算法,设计模式。都是这里面的关键基础和重点需要熟练的。
NDK开发;
未来的方向,高薪必会。
前沿技术;
组件化,热升级,热修复,框架设计
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
我在搭建这些技术框架的时候,还整理了系统的高级进阶教程,会比自己碎片化学习效果强太多,CodeChina上可见;
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!
;
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!