封装Activity基类,快速实现添加标题栏,设置状态栏样式

这篇博客介绍如何封装一个BaseActivity,包含自定义标题栏样式和状态栏配置。通过抽象方法,子类可以轻松定制标题栏的各个元素和状态栏效果,简化Android应用开发。
摘要由CSDN通过智能技术生成

本篇博客是在网上学习快速封装一个ToolBar的基类的灵感,作了一定程度的衍生。
第一步:创建一个BaseActivity并在其布局文件中设定标题栏的样式,FrameLayout是用于装载子类Activity的布局。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:id="@+id/topbar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorPrimary">
        <ImageButton
            android:scaleX="0.5"
            android:scaleY="0.5"
            android:id="@+id/left_btn"
            android:layout_width="50dp"
            android:layout_height="50dp"/>
        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            android:layout_centerInParent
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值