在drawable目录下,新建一个 shape_border_top_bottom.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- item 的top left right bottom 相当于margin 设置不需要的边为负值 -->
<item
android:top="-1dp"
android:left="-1dp"
android:right="-1dp">
<shape>
<!-- 边框颜色 -->
<stroke
android:width="0.6dp"
android:color="@color/c_d0c4ae"/>
<!-- 背景填充 -->
<solid android:color="@color/bg_title_bar"/>
</shape>
</item>
</layer-list>
怎么用这个文件就不用多逼逼了吧,直接当background用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/shape_border_top_bottom"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.sanxin.ttreader.view.SearchEditText
android:id="@+id/searchEditText"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:background="@drawable/shape_search_bg"
android:drawableLeft="@mipmap/search"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:hint="@string/search_edittext_hint"
android:textColorHint="@color/c_958669"
android:imeOptions="actionSearch"
android:maxLines="1"
android:padding="5dp"
android:textCursorDrawable="@drawable/shape_text_cursor_drawable"
android:textSize="16sp"
app:drawableDel="@mipmap/main_seach" />
<TextView
android:id="@+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="4dp"
android:textColor="@color/c_4C3D1B"
android:text="@string/cancel" />
</LinearLayout>
网友评论