本文实例为大家分享了Android自定义顶部标题栏展示的具体代码,供大家参考,具体内容如下
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android " android: id=癅 + id/layout_titlebar” android: layout_width=" match_parent " android: layout_height=" 52 dp " android:背景=" # ed4255”比; & lt; TextView android: id=癅 + id/text_title” android: layout_width=" match_parent " android: layout_height=" match_parent " android: ellipsize=罢信啤? android:重力=" center_horizontal |中心” android:单行模式=" true " android:文本="标题栏” android:输入textColor=" # ffffffff” android: textSize=" 20 dp/比; & lt;按钮 android: id=癅 + id/button_backward” android: layout_width=" 60 dp " android: layout_height=" match_parent " android:背景=" @drawable/title_button_selector” android: drawableLeft=" @drawable/back_arrow” android: drawablePadding=" 6 dp " android: ellipsize="结束" android:重力="中心" android: onClick=" onClick " android: paddingLeft=" 5 dp " android:单行模式=" true " android:文本="返回” android:输入textColor=" # ffffffff” android: textSize=" 18 dp " android:可见性=耙巍?比; & lt;按钮 android: id=癅 + id/button_forward” android: layout_width=" 60 dp " android: layout_height=" match_parent " android: layout_alignParentRight=" true " android:背景=" @drawable/title_button_selector” android: drawablePadding=" 6 dp " android: ellipsize="结束" android:重力="中心" android: onClick=" onClick " android: paddingLeft=" 5 dp " android:单行模式=" true " android:文本="提交” android:输入textColor=" # ffffffff” android: textSize=" 18 dp " android:可见性=耙巍?比; & lt;/RelativeLayout>>之前
定义控制标题栏按钮和标题栏以下内容的布局
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android " android: layout_width=" match_parent " android: layout_height=" match_parent " 面向android:=按怪薄北? & lt; !——标题比; & lt;包括布局=癅layout/layout_titlebar”/比; & lt; FrameLayout android: id=癅 + id/layout_content” android: layout_width=" match_parent " android: layout_height=" match_parent " android:背景=" # fff“比; & lt;/FrameLayout> & lt;/LinearLayout> >之前注:此处使用& lt; include>标签引入标题栏,且下方有定义一个空的FrameLayout的布局。
定义TitleActivity控制按钮及布局
包org.gaochun.widget; 进口org.gaochun.ui.R; 进口android.app.Activity; 进口android.os.Bundle; 进口android.view.View; 进口android.view.View.OnClickListener; 进口android.view.ViewGroup.LayoutParams; 进口android.widget.Button; 进口android.widget.FrameLayout; 进口android.widget.TextView; 进口android.widget.Toast;/* * * @author gao_chun *自定义标题栏 */公共类TitleActivity扩展活动实现alt=" Android自定义顶部标题栏”>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
Android自定义顶部标题栏