android - Snackbar Not showing up with fragment and swiperefresh layout -
i want show snackbar fragment , layout xml goes this
activity_main.xml
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/snackbar_holder" tools:context=".mainactivity"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.noactionbar.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:contentinsetend="0dp" app:contentinsetleft="0dp" app:contentinsetright="0dp" app:contentinsetstart="0dp" app:contentinsetstartwithnavigation="0dp" app:layout_scrollflags="scroll|enteralways|snap" app:popuptheme="@style/apptheme.noactionbar.popupoverlay" /> </android.support.design.widget.appbarlayout> <include layout="@layout/content_main" /> <com.github.clans.fab.floatingactionbutton android:id="@+id/fab_refresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|bottom" android:layout_marginbottom="108dp" android:layout_marginright="8dp" android:src="@drawable/ic_refresh" app:fab_colornormal="@color/white" app:fab_colorpressed="@color/greylight" app:fab_colorripple="@color/grey_dull" app:fab_hideanimation="@anim/scale_down" app:fab_showanimation="@anim/scale_up" app:fab_size="mini" /> <view android:id="@+id/separator" android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/white_like_bg_darker" app:layout_anchor="@+id/bnv_section_selector" app:layout_anchorgravity="top" /> <android.support.design.widget.bottomnavigationview android:id="@+id/bnv_section_selector" android:layout_width="match_parent" android:layout_height="56dp" android:layout_gravity="bottom" app:itembackground="@color/white" app:itemicontint="@drawable/bottom_navigation_selector" app:itemtextcolor="@drawable/bottom_navigation_selector" app:menu="@menu/bottom_navigation_main" /> </android.support.design.widget.coordinatorlayout>
content_main.xml
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".mainactivity" tools:showin="@layout/app_bar_main"> </framelayout>
fragment inflated in framelayout
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white_like_bg"> <relativelayout android:id="@+id/swipe_view_holder" android:layout_width="match_parent" android:layout_height="wrap_content"> <horizontalscrollview android:id="@+id/buttonlayout" android:layout_width="match_parent" android:layout_height="@dimen/strip_height_price" android:layout_alignparenttop="true" android:layout_marginbottom="1dp" android:background="@color/white_like_bg" android:scrollbars="none"> <linearlayout android:id="@+id/strip" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal" /> </horizontalscrollview> <view android:id="@+id/shadow" android:layout_width="match_parent" android:layout_height="@dimen/element_padding" android:layout_below="@+id/buttonlayout" android:background="@drawable/shadown" /> <relativelayout android:id="@+id/ll_filter_result" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:gravity="center_vertical" android:orientation="horizontal" android:visibility="gone"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_margin="8dp" android:layout_toleftof="@+id/iv_cross" android:text="filtered results" /> <imageview android:id="@+id/iv_cross" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:background="?attr/selectableitembackground" android:padding="4dp" android:src="@drawable/ic_close" /> </relativelayout> </relativelayout> <radiogroup android:id="@+id/rg_logistics_selector" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/swipe_view_holder" android:layout_centerhorizontal="true" android:orientation="horizontal" android:visibility="gone"> <radiobutton android:id="@+id/rb_logistics_tab_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="8dp" android:background="@drawable/checkable_bg_selector" android:button="@null" android:paddingbottom="8dp" android:paddingleft="16dp" android:paddingright="16dp" android:paddingtop="8dp" android:text="@string/iron_ore" android:textcolor="@color/checkable_text_color_selector" /> <radiobutton android:id="@+id/rb_logistics_tab_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="8dp" android:background="@drawable/checkable_bg_selector" android:button="@null" android:paddingbottom="8dp" android:paddingleft="16dp" android:paddingright="16dp" android:paddingtop="8dp" android:text="@string/coal" android:textcolor="@color/checkable_text_color_selector" /> <radiobutton android:id="@+id/rb_logistics_tab_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="8dp" android:background="@drawable/checkable_bg_selector" android:button="@null" android:paddingbottom="8dp" android:paddingleft="16dp" android:paddingright="16dp" android:paddingtop="8dp" android:text="@string/met_coke" android:textcolor="@color/checkable_text_color_selector" /> </radiogroup> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/rg_logistics_selector"> <android.support.v4.widget.swiperefreshlayout android:id="@+id/swipecontainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top"> <se.emilsjolander.stickylistheaders.stickylistheaderslistview android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="@dimen/head_padding" android:layout_marginright="@dimen/head_padding" android:layout_margintop="@dimen/head_padding" android:cliptopadding="false" android:nestedscrollingenabled="true" android:paddingbottom="@dimen/row_height" android:visibility="visible" /> </android.support.v4.widget.swiperefreshlayout> <textview android:id="@+id/message_textview" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:clickable="true" android:gravity="center" android:padding="@dimen/outer_padding" android:textcolor="@color/text_grey" android:textsize="@dimen/textsizehighlight" android:visibility="gone" /> <relativelayout android:id="@+id/progresslayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:clickable="true" android:visibility="gone"> <progressbar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" /> </relativelayout> </framelayout> </relativelayout>
i have added snackbar. it's not showing up. here's code i've used show snackbar
view parent = getactivity().findviewbyid(r.id.snackbar_holder); snackbar.make(parent, "seems logged out", basetransientbottombar.length_long).show();
even have tried show in mainactivity no luck... missing ?
try this
coordinatorlayout parent = (coordinatorlayout)getactivity().findviewbyid(r.id.snackbar_holder) snackbar snackbar = snackbar.make(parent , "seems logged out", snackbar.length_short); view sbview = snackbar.getview(); textview textview = (textview) sbview.findviewbyid(android.support.design.r.id.snackbar_text); textview.settextcolor(color.yellow); snackbar.show();
Comments
Post a Comment