zoukankan      html  css  js  c++  java
  • [Android] SearchView 美化成圆角效果

    先来看一下美化了背景后的效果图 

    bg_searchview.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
        <!-- 角度 -->
        <corners android:radius="35dp"/>
        <!-- 填充色 -->
        <solid android:color="@color/background_menu"/>
        <!-- 描边 设置线宽及颜色 -->
        <stroke android:color="@color/background_menu" android:width="0.5dp"/>
    </shape>

    SearchView 使用

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.appcompat.widget.SearchView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/search_view"
            android:theme="?attr/actionBarStyle"
            android:background="@drawable/bg_searchview"
            android:layout_width="match_parent"
            android:layout_height="34dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:imeOptions="actionSearch"
            app:queryBackground="@drawable/bg_searchview"
            app:submitBackground="@color/transparent"
            app:defaultQueryHint="搜索"/>

    就这样, 不改一行代码就完事了.

  • 相关阅读:
    【ZJ选讲·压缩】
    【ZJ选讲·调整】
    【ZJ选讲·钻石游戏】
    【ZJ选讲·BZOJ 5073】
    【ZJ选讲·BZOJ 5071】
    【模拟赛·polyline】
    【BZOJ 2744 朋友圈】
    【BZOJ 2241 打地鼠】
    【CF edu 30 D. Merge Sort】
    【CF edu 30 C. Strange Game On Matrix】
  • 原文地址:https://www.cnblogs.com/yangyxd/p/12509912.html
Copyright © 2011-2022 走看看