Android经典布局之top title

来源:互联网 发布:linux的tar xvf 编辑:程序博客网 时间:2024/05/22 13:59

我感觉这种布局会在Android开发中经常遇到,也体现了比较经典的布局方式,届时直接拷贝即可,遂编此博客。

布局描述:top title布局,一个返回键、标题名、更多键。如下图:


以下是top_title.xml的源码

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="@dimen/main_head_title_height"    android:background="@drawable/app_title_bg"    android:gravity="center_vertical"    android:padding="0.0px" >    <TextView        android:id="@+id/top_title_text"        android:layout_width="wrap_content"        android:layout_height="@dimen/main_head_title_height"        android:layout_centerInParent="true"        android:gravity="center"        android:text="此处填写标题"        android:textColor="@color/color_common_black_text"        android:textSize="@dimen/main_head_title_text_size" />    <ImageButton        android:id="@+id/top_back_btn"        android:layout_width="@dimen/main_head_title_back_width"        android:layout_height="@dimen/main_head_title_back_height"        android:layout_centerVertical="true"        android:layout_marginLeft="10dp"        android:layout_toLeftOf="@id/main_title_text"        android:background="@drawable/app_title_back"        android:contentDescription="@string/descr_image" >    </ImageButton>    <ImageButton        android:id="@+id/top_setting_btn"        android:layout_width="@dimen/setting_button_width"        android:layout_height="@dimen/setting_button_height"        android:layout_alignParentRight="true"        android:layout_centerVertical="true"        android:layout_marginRight="10dp"        android:background="@drawable/top_title_setting"        android:contentDescription="@string/descr_image"        android:visibility="visible" /></RelativeLayout>




0 0
原创粉丝点击