如何使头在Android的文字和按钮的iOS中 [英] how to make headers in android with text and buttons like in iOS
本文介绍了如何使头在Android的文字和按钮的iOS中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建Android中使用文本和按钮的头就像iOS中(在Cetner文字和左右两侧的按钮),我已经尝试过,但没有作用的,请指导我...我怎么能做出这种一个是我的应用程序
i want to create header in android with text and buttons like in iOS (Text in Cetner and Buttons on right and left side), i have tried but not useful at all,please guide me ... how can i make this one for my app
推荐答案
试试这个。制作header.xml文件,并把低于code中,并使用它用在任何布局文件包括
。
Try this. Make header.xml file and put below code in it and use it in any layout file using include
.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/titlebar"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back_button"
android:background="@android:color/transparent"
android:layout_marginLeft="5.0dip"
android:id="@+id/imageButtonBack"
android:contentDescription="@string/ui_image_home_description"/>
<TextView
android:id="@+id/textViewTitleBar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="@style/TitleBarText"
android:singleLine="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/home_button"
android:background="@android:color/transparent"
android:layout_marginRight="5.0dip"
android:id="@+id/imageButtonHome"
android:contentDescription="@string/ui_image_home_description"/>
</LinearLayout>
注:添加下面的样式资源来style.xml /值文件夹
Note : Add the below style to style.xml in res/values folder.
<style name="TitleBarText">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize"> 17sp </item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:textColor">@color/white</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
这篇关于如何使头在Android的文字和按钮的iOS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文