How to set or remove android SearchView top and bottom padding? -
i develop android apps. use searchview in application. want customise it.but don't remove it's top , bottom padding.when searchview's height decrements,textbox drowned.flowing output view-
i want to-
xml layout code:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <searchview android:id="@+id/search_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:background="@drawable/search_text" /> <listview android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"/> </linearlayout>
java code:
public class searchviewfiltermode extends activity implements searchview.onquerytextlistener { private searchview msearchview; private listview mlistview; private final string[] mstrings = cheeses.scheesestrings; private arrayadapter<string> adaptor; android.widget.filter filter ; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().requestfeature(window.feature_action_bar); setcontentview(r.layout.searchview_filter); msearchview = (searchview) findviewbyid(r.id.search_view); mlistview = (listview) findviewbyid(r.id.list_view); adaptor=new arrayadapter<string>(this, android.r.layout.simple_list_item_1, mstrings); filter = adaptor.getfilter(); mlistview.setadapter(adaptor); mlistview.settextfilterenabled(false); setupsearchview(); } private void setupsearchview() { msearchview.setpadding(0, 0, 0, 0); msearchview.setpaddingrelative(0, 0, 0, 0); linearlayout.layoutparams seachv = new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, 75); seachv.setmargins(5,10, 5, 0); msearchview.setlayoutparams(seachv); msearchview.setbackgroundresource(r.drawable.search_text); edittext e = (edittext)msearchview.findviewbyid(msearchview.getcontext().getresources().getidentifier("android:id/search_src_text", null, null)); e.setbackgroundresource(r.drawable.search_text); int searchplateid = msearchview.getcontext().getresources() .getidentifier("android:id/search_plate", null, null); view searchplateview = msearchview.findviewbyid(searchplateid); if (searchplateview != null) { searchplateview.setbackgroundcolor(color.white); } msearchview.seticonifiedbydefault(false); msearchview.setonquerytextlistener(this); msearchview.setsubmitbuttonenabled(true); msearchview.setqueryhint("search here"); } @override public boolean onquerytextchange(string newtext) { filter.filter(newtext); return true; } public boolean onquerytextsubmit(string query) { return false; } }
any hints , example helpful.
you not explain properly. want customize searchview layout. linearlayout.you go "*\path-to-your-android-sdk-folder\platforms\android-xx\data\res\layout*" , find search_view layout. , searchview class here. customize programmatically.
Comments
Post a Comment