因為沒有美工, 所以只能自己動手了。
在layout文件夾里的xml 寫
方法1:在layout里面的布局xml 文件里加上面的代碼
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/orange_normal" />
效果圖
在drawable文件夾里用 shape line 或 rectangle 先畫線
方法2:在drawable里面用shape新建一個xml
然后在 layout 里的布局文件里引用
這種方法 可以 多處引用同一個 line 樣式
<!-- drawable/line_my.xml --><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:color="@color/orange_normal" /></shape>
或者用填充的矩形實現
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@color/orange_normal" /> <size android:height="1dp" android:width="100dp" /></shape>
Note
android:width=”100dp” 不能賦值為 “match_parent”
在layout/bomb_fragment.xml 里面引用
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/line_my" />
希望本文所述對大家學習Android軟件編程有所幫助。
新聞熱點
疑難解答
圖片精選