其他分享
首页 > 其他分享> > android – 想要更改searchView的边框颜色

android – 想要更改searchView的边框颜色

作者:互联网

我想更改searchview的边框颜色.现在它变得透明了.我尝试给它造型但没有任何效果.

SearchView.xml

 <LinearLayout
        android:id="@+id/linear1"
        android:background="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1">

    <android.support.v7.widget.SearchView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:id="@+id/searchView"
        android:background="@android:color/white"
        android:layout_marginTop="10dp"

style=”@style/CitySearchView”

        android:layout_weight="0.9"
        android:layout_marginLeft="10dp"/>

style.xml

<style name="CitySearchView" parent="Widget.AppCompat.Light.SearchView">
        <item name="searchIcon">@drawable/blue_search_bar</item>
        <item name="colorControlActivated">@color/labelColorHighligh</item>
        <item name="colorControlNormal">@color/backgroud_user</item>
        <item name="queryBackground">@color/labelColorHighligh</item>

    </style>

解决方法:

1)创建文件夹drawable

2)在create background.xml中绘制

3)background.xmal在写这段代码

 <?xml version="1.0" encoding="UTF-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:padding="12dp"
 android:shape="rectangle" >
 <solid android:color="#FFFFFF" />
  <stroke
    android:width="0.3dp"
    android:color="#797979" />
 </shape>

更改SearchView teg

    <android.support.v7.widget.SearchView
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:id="@+id/searchView"
    android:background="@drawable/background"
    android:layout_marginTop="10dp"/>

标签:android,android-styles,android-view,android-search
来源: https://codeday.me/bug/20190824/1704964.html