appcompat - How to remove the Android SearchView left space? -
i'm trying remove left space before search view of android, without success. tried every answer found on internet didn't work. i'm using appcompat themes activity. i'm targeting kitkat api (19).
edit
layout of activity
<?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" />
menu
<?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>
the iconified stuff did programatically because when change xml didn't work
edit if set background color of searchview
the search doesn't fit entire space. why?
you can following:
hide app bar in oncreate()
so:
// hide ui first actionbar actionbar = getsupportactionbar(); if (actionbar != null) { actionbar.hide(); }
in layout file set background green (or colour), add searchview
, set background searchview
white so:
<android.support.constraint.constraintlayout ... android:background="#00ff00" ...> <android.support.v7.widget.searchview android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fff" /> ... <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello world!" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" /> .... </android.support.constraint.constraintlayout>
i pretty sure other search interface code shall work. need redirect event calls.
Comments
Post a Comment