我正在尝试删除Android搜索视图前面的左空格,但没有成功。我尝试了互联网上找到的每个答案,但都没有奏效。我为此活动使用AppCompat主题。我针对KitKat api(19)进行定位。
有人能帮助我吗?
编辑
活动布局
我以编程方式创建了缩小的图标,因为当我更改xml时无法正常工作。 编辑 如果我设置SearchView的背景颜色。
有人能帮助我吗?
![enter image description here](https://istack.dev59.com/Se9A5.webp)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/MainLayout"
android:background="#6ED19E">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/BackgroundLayout"
android:background="#6ED19E">
<ImageView
android:src="@drawable/bgpattern"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/PatternImageView"
android:scaleType="centerCrop" />
<TextView
android:text="Já estamos em muitas cidades\nEstamos na sua?"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ManyCityLabel"
android:textColor="#ffffff"
android:textSize="25dp"
android:width="20dp"
android:gravity="center"
android:textStyle="normal" />
</RelativeLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/LocationsListView"
android:background="#ffffff"
android:visibility="invisible" />
菜单
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<item android:id="@+id/LocationSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:showAsAction="always"
tools:actionViewClass="android.support.v7.widget.SearchView"/>
</menu>
我以编程方式创建了缩小的图标,因为当我更改xml时无法正常工作。 编辑 如果我设置SearchView的背景颜色。
搜索框不适合整个空间。 为什么?