Android---添加結構線或邊框的幾種方式

一.自定義View(該方法已經太過老舊)

<!--豎邊框-->
<LinearLayout
android:layout_width="1px"
android:layout_height="match_parent">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_text_gamesize" />
</LinearLayout>
<!--橫邊框-->
<LinearLayout
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_text_gamesize"
/>
android:layout_width="match_parent"
android:layout_height="1px">
</LinearLayout>
<!--豎線-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="1px"
android:layout_height="60dp"
android:background="@color/color_line_border"
android:layout_marginRight="30dp" />
</LinearLayout>

二.自定義Layout

使用時以下兩種層級關係靈活運用:

1.與要添加邊框的佈局(控件)平級

2.是要添加邊框的佈局(控件)的子佈局

<RelativeLayout
android:background="@color/color_border"
android:layout_width="match_parent"
android:layout_height="2px"
android:layout_above="@+id/rl_content_top"></RelativeLayout>
<LinearLayout
android:background="@color/color_border"
android:layout_width="match_parent"
android:layout_height="2px"
android:layout_below="@id/sv_nav"></LinearLayout>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章