这是我的布局XML:为什么我的TextView在LinearLayout中无边框显示?
而且
<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>
这使得水平线出现TextView
秒之间,但我期待的边界围绕着TextView
的文字本身。我如何做到这一点?
可能只使用'wrap_content'的高度属性在你的第二个TextView – convexHull
从视图中删除它:android:background =“@ drawable/border”并为其提供颜色,它将起作用。 –