当光标聚焦并移动时,android searchView 背景会将文本隐藏在白色框后面

问题描述 投票:0回答:1
java android searchview
1个回答
0
投票

使用这样的代码

        MenuItem searchItem = menu.findItem(R.id.action_search);
        SearchView filterPartsSearchView = (SearchView) searchItem.getActionView();

        if (searchManager != null) {
            filterPartsSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        }

       filterPartsSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        filterPartsSearchView.setBackgroundColor(ResourcesCompat.getColor(getResources(), android.R.color.transparent, null));
 
        View searchPlate = filterPartsSearchView.findViewById(androidx.appcompat.R.id.search_plate);
        if (searchPlate != null) {
            searchPlate.setBackgroundColor(Color.TRANSPARENT);
        }

这是所选文本的参考图像

This is Ref Image of selected text

按下光标并按住突出显示文本时的第二张图像参考,同时在文本周围移动光标

nd highlight text while cursor moving around text

© www.soinside.com 2019 - 2024. All rights reserved.