Java /p>

Java /p>,java,android,textview,Java,Android,Textview,只需在可绘制文件夹中创建一个名为box\u border.xml的可绘制文件 <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:col

只需在可绘制文件夹中创建一个名为box\u border.xml的可绘制文件

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke android:color="@color/navy"/>
    <stroke android:width="1dp"/>
    <corners android:radius="00dp"/>
</shape>


并将其设置为文本视图的背景音

<TextView
        android:id="@+id/cs_textview_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/select_characters"
        android:textSize="25sp"
        android:textColor="@color/white"
        android:background="@drawable/box_border"
        />
</androidx.appcompat.widget.LinearLayoutCompat>



希望能有帮助。根据需要在尽可能多的文本视图中使用它。如果您还需要其他内容,请发布一张图片。

只需在您的可绘制文件夹中制作一个名为box\u border.xml的可绘制文件即可

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke android:color="@color/navy"/>
    <stroke android:width="1dp"/>
    <corners android:radius="00dp"/>
</shape>


并将其设置为文本视图的背景音

<TextView
        android:id="@+id/cs_textview_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/select_characters"
        android:textSize="25sp"
        android:textColor="@color/white"
        android:background="@drawable/box_border"
        />
</androidx.appcompat.widget.LinearLayoutCompat>



希望能有帮助。根据需要在尽可能多的文本视图中使用它。如果你想要其他内容,请发布一张图片。

嗨,你想在TextView的整个文本或其中的一部分文本周围加上边框吗?@Zain我上传了一张图片,上面有一个示例,说明我需要TextView的文本看起来如何。我不确定边框;您的意思是文本字母有一个空白的内部间隙吗?同样在xml组件中,使用OutlineTextView而不是AppCompatTextView@Zain不,我是指文本周围的黑色边框。嗨,你想在TextView的整个文本或其中的一部分文本周围加上边框吗?@Zain我上传了一张图片,上面有一个示例,说明我需要如何使TextView的文本看起来像。我不确定边框;您的意思是文本字母有一个空白的内部间隙吗?同样在xml组件中,使用OutlineTextView而不是AppCompatTextView@Zain不,我指的是文本周围的黑色边框。好吧,我按照你的建议做了,结果如下-之前:和之后:我的意思是,它确实有效,但不像预期的那样,因为我的文本不需要阴影,但是在我的文本周围有一个纯色和固定大小的轮廓/边框(例如6dp)。还有什么想法吗?好的,我按照你的建议做了,下面是结果-之前:和之后:我的意思是,它确实起作用了,但不像预期的那样,因为我的文本不需要阴影,而是在文本周围有一个纯色和固定大小的轮廓/边框(例如6dp)。还有什么想法吗?