其他分享
首页 > 其他分享> > SearchView

SearchView

作者:互联网

 去除下划线
val viewid = searchview.findViewById<View>(R.id.search_plate)
        if (viewid != null) {
            viewid.setBackgroundColor(Color.TRANSPARENT)
        }

<androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/titleBar22"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="@color/xx"
        android:elevation="2dp"
        android:visibility="visible"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/titleBar">

        <ImageView
            android:id="@+id/ivBackBtn22"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/xx"
            android:src="@drawable/xx"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <androidx.appcompat.widget.SearchView
            android:id="@+id/searchview"
            android:layout_width="0dp"
            android:layout_height="36dp"
            android:layout_marginEnd="@dimen/xx"
            android:background="@drawable/xx"
            app:closeIcon="@drawable/ic_icon_close"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/xx"
            app:layout_constraintTop_toTopOf="parent"
            app:queryHint="@string/xx"
            app:searchHintIcon="@drawable/xx" />
    </androidx.constraintlayout.widget.ConstraintLayout>





<androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/titleBar22"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="@color/p_ochat_white"
        android:elevation="2dp"
        android:visibility="visible"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/titleBar"
        app:title="Select contacts">

        <ImageView
            android:id="@+id/ivBackBtn22"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/p_ochat_dp_16"
            android:src="@drawable/p_ochat_ic_back_black"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <androidx.appcompat.widget.SearchView
            android:id="@+id/searchview"
            android:layout_width="0dp"
            android:layout_height="36dp"
            android:layout_marginEnd="@dimen/p_ochat_dp_20"
            android:background="@drawable/p_ochat_search_bg"
            app:closeIcon="@drawable/ic_icon_close"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/ivBackBtn22"
            app:layout_constraintTop_toTopOf="parent"
            app:queryHint="@string/p_ochat_search_friends"
            app:searchHintIcon="@drawable/p_ochat_ic_icon_searchhbar_small" />
    </androidx.constraintlayout.widget.ConstraintLayout>



 fun searchAction() {
        searchview.findViewById<View>(R.id.search_plate)?.setBackgroundColor(Color.TRANSPARENT)
        searchview.setOnQueryTextListener(object :SearchView.OnQueryTextListener{
            override fun onQueryTextSubmit(query: String?): Boolean {
                return false
            }

            override fun onQueryTextChange(newText: String?): Boolean {
               return false
            }
        })
        searchview.onActionViewExpanded()
    }

 

标签:false,viewid,SearchView,searchview,fun,id
来源: https://blog.csdn.net/page1001/article/details/109900790