Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中的标题边框?_Android_Border_Shapes - Fatal编程技术网

Android中的标题边框?

Android中的标题边框?,android,border,shapes,Android,Border,Shapes,我们可以使用shape创建一个简单的边框,例如,我看到以下代码: 但我需要一个标题如下图所示的边框: 我如何做到这一点?尝试以下代码,并在应用程序的res/drawable文件夹中创建xml文件,然后粘贴以下代码: 通过更改笔划颜色,可以根据您的方便更改边框颜色 使用上面的xml如下:这里我尝试在TextView上设置边框 我希望它能帮助你 谢谢。现在我发现了一个很好的代码,可以帮助我。我在这里添加代码: <?xml version="1.0" encoding="utf-8

我们可以使用
shape
创建一个简单的边框,例如,我看到以下代码:


但我需要一个标题如下图所示的边框:


我如何做到这一点?

尝试以下代码,并在应用程序的
res/drawable
文件夹中创建xml文件,然后粘贴以下代码:


通过更改笔划颜色,可以根据您的方便更改边框颜色

使用上面的xml如下:这里我尝试在TextView上设置边框


我希望它能帮助你


谢谢。

现在我发现了一个很好的代码,可以帮助我。我在这里添加代码:

<?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>

@drawable/rectangle位于drawable rectangle.xml文件中,如下所示:

<?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>


该图像是否来自web表单?是否要在
安装
文本周围添加边框?它是应用程序的布局吗?如果是,请张贴您的密码layout@Grishu谢谢,但这不是我想要的。这是一个简单的边界。我想要一个边界,它的标题有一个地方,它的标题必须在边界之上。
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:text="@string/hello_world" />
<?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>
<?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>