【发布时间】:2017-05-30 05:30:57
【问题描述】:
这是我的布局 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/border" />
<TextView android:text="ahahah 2!"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/border"
xmlns:android="http://schemas.android.com/apk/res/android" />
</LinearLayout>
这是边界定义:
<?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/white" />
<stroke android:width="1dip" android:color="#4fa5d5"/>
</shape>
这会使TextViews 之间出现一条水平线,但我希望TextViews 本身的文本周围有一个边框。我该如何做到这一点?
【问题讨论】:
-
可能只使用
wrap_content作为第二个TextView 的高度属性 -
从 View 中删除它:android:background="@drawable/border" 并为其提供颜色,它将起作用。
标签: android android-layout android-linearlayout textview