如何创建一个Android的标题边框? [英] How to create a titled border in Android?
本文介绍了如何创建一个Android的标题边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个人一个想法如何创建一个标题边框布局像挥杆的?
has someone an idea how to create a titled border layout like in swing?
在<一个href="http://stackoverflow.com/questions/1598119/is-there-an-easy-way-to-add-a-border-to-the-top-and-bottom-of-an-android-view">this现场我发现了一个窍门,以产生一个对象之间的矩形。也许这可以帮助我创造这样一个标题边框?
On this site i found a trick to generate a rectangle between a object. Maybe this can help me to create such a titled border?
问候
推荐答案
快速和肮脏的:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:color="#000000">
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rectangle"
android:layout_margin="20dp"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#000000"
android:layout_marginTop="10dp"
android:text="TITLE!"
android:textColor="#ffffff"/>
</RelativeLayout>
</FrameLayout>
和 @绘制/矩形
是一个绘制 rectangle.xml
文件是这样的:
And @drawable/rectangle
is in a drawable rectangle.xml
file like this:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke android:width="2dip" android:color="#ffffff"/>
</shape>
这篇关于如何创建一个Android的标题边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文