這是我的佈局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」併爲其提供顏色,它將起作用。 –