介绍
这篇文章给大家介绍Android应用中怎么实现自定义状态栏,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
<强> 1,在res-values-colors。xml下新建一个RGB颜色强>
& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比; http://schemas.android.com/apk/res/android" & lt; LinearLayout xmlns: android=?; android:取向=皏ertical" android: layout_width=癿atch_parent" android: layout_height=皐rap_content"比; & lt; TextView android: id=癅 + id/actionBarId" android: layout_width=癿atch_parent" android: layout_height=皐rap_content"/比; & lt;/LinearLayout>
<强> 3,重写LineaLayout布的局,放置步骤二新建的布局在顶部,用作背景颜色的容器强>
公共类ActionBarLayOut LinearLayout{延伸 公共ActionBarLayOut(上下文语境,AttributeSet attrs) { 超级(上下文,attrs); LayoutInflater.from(上下文).inflate (R.layout.actionbarlayout,); } }
<强> 3,在主布局里调用这个重写后的线性布局强>
& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比; & lt; com.example.test。ActionBarLayOut xmlns: android=癶ttp://schemas.android.com/apk/res/android" xmlns:工具=癶ttp://schemas.android.com/tools" android: id=癅 + id/activity_main" android: layout_width=癿atch_parent" android: layout_height=癿atch_parent" android:取向=皏ertical" 工具:上下文=癱om.example.test.MainActivity"比; & lt; TextView android: layout_width=癿atch_parent" android: layout_height=皐rap_content" android:背景=癅color/theRed" android:文本=癏ello World !“/比; & lt;/com.example.test.ActionBarLayOut>
, <强> 4,在主要活动中进行相应设置强>
公共类MainActivity延伸AppCompatActivity { @Override 保护空白>关于Android应用中怎么实现自定义状态栏就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。Android应用中怎么实现自定义状态栏