android - Unexpected margin in bottom sheet after using SearchView -
i facing strange issue working searchview
, bottomsheet
.
bottomsheet
gets unexpected margin when used after using searchview
. video explains problem.
xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout <xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/backgroundcolor" android:fitssystemwindows="true"> <android.support.v7.widget.recyclerview android:id="@+id/trip_recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" /> <android.support.v4.widget.nestedscrollview android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/backgroundcolor" android:cliptopadding="false" app:layout_behavior="android.support.design.widget.bottomsheetbehavior"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="32dp" android:orientation="vertical" android:padding="12dp"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentstart="true" android:text="sort & filter" android:textcolor="@color/black" android:textsize="18sp" android:textstyle="bold" /> <textview android:id="@+id/sheet_done" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentend="true" android:drawablepadding="8dp" android:drawablestart="@drawable/ic_done" android:text="done" android:textsize="18sp" /> </relativelayout> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="12dp" android:text="sort by" /> <android.support.v7.widget.cardview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="8dp"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <spinner android:id="@+id/sheet_spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/sort_by" android:padding="8dp" /> </linearlayout> </android.support.v7.widget.cardview> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="12dp" android:text="price range" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="8dp" android:layout_marginend="12dp" android:layout_marginstart="12dp" android:layout_margintop="8dp" android:orientation="horizontal"> <textview android:id="@+id/sheet_price_min" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <textview android:id="@+id/sheet_price_max" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="end" android:gravity="end" /> </linearlayout> <seekbar android:id="@+id/sheet_bar_price" android:layout_width="match_parent" android:layout_height="wrap_content" android:thumb="?android:attr/textselecthandle" /> <textview android:id="@+id/sheet_price_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:text="rs 1,115" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="8dp" android:text="ratings" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="8dp" android:layout_marginend="12dp" android:layout_marginstart="12dp" android:layout_margintop="8dp" android:orientation="horizontal"> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginstart="12dp" android:layout_weight="1" android:gravity="start" android:text="2" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="3" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginend="12dp" android:layout_weight="1" android:gravity="end" android:text="4" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="end" android:text="5" /> </linearlayout> <seekbar android:id="@+id/sheet_bar_rating" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="4" android:thumb="?android:attr/textselecthandle" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="12dp" android:text="packages" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <checkbox android:id="@+id/sheet_package_gold" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="12dp" android:layout_marginright="12dp" android:layout_weight="1" android:text="gold" /> <checkbox android:id="@+id/sheet_package_diamond" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="12dp" android:layout_marginright="12dp" android:layout_weight="1" android:text="diamond" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <checkbox android:id="@+id/sheet_package_silver" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="12dp" android:layout_marginright="12dp" android:layout_weight="1" android:text="silver" /> <checkbox android:id="@+id/sheet_package_platinum" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="12dp" android:layout_marginright="12dp" android:layout_weight="1" android:text="platinum" /> </linearlayout> </linearlayout> </android.support.v4.widget.nestedscrollview> </android.support.design.widget.coordinatorlayout>
activity
public class tripsactivity extends appcompatactivity implements searchview.onquerytextlistener, seekbar.onseekbarchangelistener, view.onclicklistener { public string max = "150000"; public string min = "0"; @bindview(r.id.trip_recyclerview) recyclerview recyclerview; @bindview(r.id.bottom_sheet) view view; @bindview(r.id.sheet_spinner) spinner spinner; @bindview(r.id.sheet_price_min) textview minprice; @bindview(r.id.sheet_price_max) textview maxprice; @bindview(r.id.sheet_price_text) textview currentprice; @bindview(r.id.sheet_bar_price) seekbar pricebar; @bindview(r.id.sheet_bar_rating) seekbar ratingbar; @bindview(r.id.sheet_package_gold) checkbox packagegold; @bindview(r.id.sheet_package_silver) checkbox packagesilver; @bindview(r.id.sheet_package_platinum) checkbox packageplatinum; @bindview(r.id.sheet_package_diamond) checkbox packagediamond; bottomsheetbehavior.bottomsheetcallback callback = new bottomsheetbehavior.bottomsheetcallback() { @override public void onstatechanged(@nonnull view bottomsheet, int newstate) { } @override public void onslide(@nonnull view bottomsheet, float slideoffset) { if (slideoffset < 0.4) getsupportactionbar().show(); else getsupportactionbar().hide(); } }; private searchview searchview; private tripsadapter adapter; private bottomsheetbehavior mbottomsheetbehavior; @onclick(r.id.sheet_done) public void onclick(view view) { switch (view.getid()) { case r.id.sheet_done: mbottomsheetbehavior.setstate(bottomsheetbehavior.state_collapsed); break; } } @override protected void oncreate(@nullable bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.layout_trips_activity); butterknife.bind(this); mbottomsheetbehavior = bottomsheetbehavior.from(view); mbottomsheetbehavior.setstate(bottomsheetbehavior.state_hidden); mbottomsheetbehavior.setpeekheight(0); mbottomsheetbehavior.setbottomsheetcallback(callback); } @override public boolean onoptionsitemselected(menuitem item) { if (item.getitemid() == android.r.id.home) { if (mbottomsheetbehavior.getstate() == bottomsheetbehavior.state_expanded) mbottomsheetbehavior.setstate(bottomsheetbehavior.state_collapsed); else this.finish(); } else if (item.getitemid() == r.id.filteroptions) mbottomsheetbehavior.setstate(bottomsheetbehavior.state_expanded); return super.onoptionsitemselected(item); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.seach_meanu, menu); final menuitem searchitem = menu.finditem(r.id.action_search); searchview = (searchview) menuitemcompat.getactionview(searchitem); searchview.setonquerytextlistener(this); return true; } @override public boolean onquerytextsubmit(string query) { adapter.filter(query); return true; } @override public boolean onquerytextchange(string newtext) { adapter.filter(newtext); return true; } @override public void onbackpressed() { if (mbottomsheetbehavior.getstate() == bottomsheetbehavior.state_expanded) mbottomsheetbehavior.setstate(bottomsheetbehavior.state_collapsed); else super.onbackpressed(); } }
someone can me identify problem. thanks
add manifest.this issue trigered softkeyboard.sadly cant find real source of problem.
<activity> android:name=.. android:windowsoftinputmode="adjustpan">
Comments
Post a Comment