My xml layout is shown below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/root_literature_fm"
android:layout_width="match_parent"
android:layout_height="match_parent">
<net.cnki.tCloud.view.widget.TitleBar
android:id="#id/base_titlebar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/root_literature_fm_literature_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/base_titlebar"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:layout_scrollFlags="scroll|enterAlways|snap">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/sdv_magazine_cover"
android:layout_width="90dp"
android:layout_height="120dp"
android:padding="13dp"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#mipmap/side_surface"
fresco:placeholderImageScaleType="centerCrop"/>
<TextView
android:id="#+id/tv_magazine_name"
style="#style/TextItemMagazineTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/sdv_magazine_cover"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="55dp"
tools:text="title"/>
<TextView
android:id="#+id/tv_magazine_date"
style="#style/TextItemMagazineSubtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/sdv_magazine_cover"
android:ellipsize="end"
android:paddingTop="55dp"
tools:text="1922"/>
</RelativeLayout>
<include layout="#layout/layout_literature_filter"/>
</android.support.design.widget.AppBarLayout>
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="#+id/xrv_literature"
android:name="net.cnki.tCloud.view.fragment.LiteratureFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="false"
app:layoutManager="LinearLayoutManager"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<ViewStub
android:id="#+id/vs_no_literature"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/base_titlebar"
android:layout="#layout/layout_literature_unbind"/>
My problem is delayed response when i slide up the screen to load data. The link is a video of the issue.https://www.youtube.com/watch?v=VaaAl-omBiY
I think this problem is setting behavior.This touch event is a delay passed to RecyclerView.
Please help me this problem has been bothering me for a long time.
this is a bug of supportlibrary,and not fixed in 27.1.0
https://issuetracker.google.com/issues/66996774
try https://gist.github.com/chrisbanes/8391b5adb9ee42180893300850ed02f2, it works
Related
I trying to achieve one layout like this:
The problem is that i cant center fragment on viewpager. I already try to change gravitys, and everything but i cant. There is some of mycode:
<android.support.design.widget.CollapsingToolbarLayout
>
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:gravity="center" />
</RelativeLayout>
(...)
</android.support.design.widget.CollapsingToolbarLayout>
Fragment child have that code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/infos"
android:weightSum="3"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
(...)</LinearLayout>
With this code im geting something like this:
Please update your layout like this:
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
/>
Feel free to tailor padding/height to fit your UI.
I am struggling to create collapsing image header alongside Constraint where my design looks like this
Currently the profile pic is a part of the ConstraintLayout because it needs Guideline constraints and unfortunately it is overlapped by the AppBarLayout
Any ideas how to achieve that?
Can't find any source regarding my combination of layouts.....
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/playerViewBg"
android:fitsSystemWindows="false">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/bgIV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/header_bg" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/playerIV"
android:layout_width="177dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="62dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/profilePic"
app:layout_constraintEnd_toStartOf="#+id/guideline2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline"
app:layout_constraintTop_toTopOf="parent" />
<!-- Other content -->
<android.support.constraint.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.27" />
<android.support.constraint.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.73" />
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
Following is the snippet of my working layout:
Please make sure that you haven't make any childview height to match parent(0 dp) inside constrianlayout also for scroll view android:fillViewport="true". Ask me if any doubt Occur.
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:fitsSystemWindows="false">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/ivImagec"
android:layout_width="wrap_content"
android:layout_height="#dimen/_90sdp"
android:contentDescription="#string/no_des"
android:scaleType="centerCrop"
app:srcCompat="#drawable/outdoorgames" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_90sdp"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/cvLayout"
android:animateLayoutChanges="true">
....
</android.support.constraint.ConstraintLayout>
I've actually recently started thinking about this
And based on this talk here from two of the devs behind Android Studio :
https://www.youtube.com/watch?v=8lAXJ5NFXTM (at the 21 mins: 28 seconds mark)
It is definitely possible, they recommend replacing the CollapsingToolbarLayout completely with the ConstraintLayout.
i have an app that uses tabs to show different content..... there is an admob banner below the tabs that should never move..... it should be locked to the bottom of the screen...........
most of the content is shown using activity_main.xml which includes content_main.xml using and i have never had a problem with the layout before..... everything fit fine.....
here is what the layout is SUPPOSE to look like....
i recently added a new tab and java file called bpm counter....
the bpm counter tab has its own layout and doesn't use activity_main.xml or the content_main.xml instead it uses its own activity_main2.xml and everything is sort of working but here is the problem....
when i open the app everything looks normal like it always has with the banner at the bottom of the page.... however when i click the bpm counter tab the admob banner moves down and goes half way of the screen....... then when i try to go back to any other tab the banner moves wayyy up and i get a white space below the admob banner
you can see the problem of the banner moving down when i visit the bpm tab here
and then when i try to go back to the home page or any other tab the banner moves way up... as you can see in the photo below
i have tried changing match_parent and fill_parent and have tried a lot of tweak in the layout but i can not figure out what i am doing wrong and i am about to bang my head off a wall.... any help would be wonderful and appreciated!
here are my .xml layout files
activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.raptools.app.raptools.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.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:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
here is my content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
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:screenOrientation="portrait"
android:background="#000000"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.raptools.app.raptools.MainActivity"
tools:showIn="#layout/activity_main">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="0dp"
android:layout_height="0dp"
android:screenOrientation="portrait"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-4075500144464557/8371434413"/>
<WebView
android:id="#+id/activity_main_webview"
android:layout_width="match_parent"
android:screenOrientation="portrait"
android:layout_height="match_parent"
android:layout_above="#id/adView" />
<ImageView
android:id="#+id/homepageimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/homepageimage"
android:layout_above="#id/adView"
/>
<ImageView
android:id="#+id/comingimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/comingsoon"
android:layout_above="#id/adView" />
</RelativeLayout>
those two layout files were working fine until i tried to add the new bpm counter tab......
here is the activity_main2.xml that is used for the bpm counter java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
tools:context="com.raptools.app.raptools.MainActivity"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:textColor="#color/ColorRemoveAds"
app:itemIconTint="#color/ColorRemoveAds"
app:popupTheme="#style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:id="#+id/appView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#drawable/transitioning_background"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".BpmCounter">
<TextView
android:id="#+id/bpmLabelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/bpm"
android:textColor="#color/textColor"
android:textSize="40sp"/>
<TextView
android:id="#+id/bpmTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/bpmLabelTextView"
android:layout_centerHorizontal="true"
android:text="#string/initial_bpm_value"
android:textColor="#color/textColor"
android:textSize="70sp"/>
<Button
android:id="#+id/tapButtonView"
android:layout_width="100dp"
android:layout_height="80dp"
android:layout_above="#+id/instructionalLabelTextView"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:background="#drawable/round_button"
android:text="#string/tap"
android:textColor="#color/textColor"
android:textSize="30sp"/>
<TextView
android:id="#+id/instructionalLabelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="28dp"
android:text="#string/reset_instructions"
android:textColor="#color/textColor"/>
</RelativeLayout>
</LinearLayout>
i hope i have explained in enough detail and any help would be amazing!
i ended up staring at the three codes i posted above for a long time and decided to copy the frame from activity_main.xml pasted it in the activity_main2.xml and removed the linear layout and made sure to include android.support.design.widget.CoordinatorLayout and i managed to get it working!
here is the working code incase anyone has this problem ever
activity_main2.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.raptools.app.raptools.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.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:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:id="#+id/appView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:screenOrientation="portrait"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_weight="1"
android:background="#drawable/transitioning_background"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".BpmCounter">
<TextView
android:id="#+id/bpmLabelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/bpm"
android:textColor="#color/textColor"
android:textSize="40sp"/>
<TextView
android:id="#+id/bpmTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/bpmLabelTextView"
android:layout_centerHorizontal="true"
android:text="#string/initial_bpm_value"
android:textColor="#color/textColor"
android:textSize="70sp"/>
<Button
android:id="#+id/tapButtonView"
android:layout_width="100dp"
android:layout_height="80dp"
android:layout_above="#+id/instructionalLabelTextView"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:background="#drawable/round_button"
android:text="#string/tap"
android:textColor="#color/textColor"
android:textSize="30sp"/>
<TextView
android:id="#+id/instructionalLabelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="28dp"
android:text="#string/reset_instructions"
android:textColor="#color/textColor"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I have xml, which consits of DrawerLayout, CoordinatorLayout with custom views, AppBarLayout, NestedScrollView.
Problem: When content in NestedtScrollView fills, NestedtScrollView scrolls down itself.
All researches like scrollView.setScrollY(0) or custom class for layout_behavior = FixedScrollingViewBehavior didn't help me.
How do i prevent this scrolling
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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="0dp"
android:layout_weight="1">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="#color/semitransparet_color_primary">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/actionbar_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:elevation="4dp"/>
</android.support.design.widget.AppBarLayout>
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<android.support.v4.widget.NestedScrollView
android:id="#+id/product_scroll_wrpr"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
// my content is here
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/buttons_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:background="#01579B"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:padding="8dp"
android:gravity="center_vertical">
// here are my buttons
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navi"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="#android:color/white"
app:headerLayout="#layout/drawer_header_left"
app:menu="#menu/nav_drawer_menu"/>
my build.gradle consits
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:design:23.0.1'
Try to set android:descendantFocusability="blocksDescendants" to the LinearLayout inside NestedScrollView. It works for me.
UPD: beware of using into the layout descendant elements like EditText, which should take a focus: that elements will not take a focus. If you know how to solve this, please let us to know.
An alternative to blocking the focus, is to add a new View that will steal the focus. Put it anywhere above the NestedScrollView, and it should work:
<!--focusStealer, to avoid NestedScrollingView to scroll due to dynamically created views that take the focus-->
<View
android:layout_width="0px" android:layout_height="0px" android:focusable="true"
android:focusableInTouchMode="true"/>
This working for me:
mNestedScrollViewChat.post(new Runnable(){
#Override
public void run(){
mNestedScrollViewChat.fullScroll(View.FOCUS_DOWN);
}
});
This worked for me in Kotlin
nestedScrollView.post { nestedScrollView.fullScroll(View.FOCUS_DOWN) }
add android:descendantFocusability="beforeDescendants" and add and android:focusableInTouchMode="true"android:focusableInTouchMode="true"' in children view of Nested ScrollView
becase nestedScrollView need focus a view before scroll. i try focus a Edittext from children of view to get focus
<EditText
android:id="#+id/edtAddressAccount"
style="#style/StyleEditText"
android:autofillHints=""
android:ems="10"
android:inputType="textPersonName"
android:singleLine="true"
android:nextFocusUp="#+id/edtAddressAccount"
android:nextFocusLeft="#id/edtAddressAccount"
app:layout_constraintEnd_toEndOf="#+id/edtDistrict"
app:layout_constraintStart_toStartOf="#+id/textView13"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
full code here
<androidx.core.widget.NestedScrollView 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:background="#color/white"
android:orientation="vertical"
android:id="#+id/nestedAccount"
android:layout_weight="1"
tools:context="jp.co.ramen.ui.auth.account.AccountFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
>
<jp.co.ramen.utils.customview.DropDown
android:id="#+id/spGenderAccount"
style="#style/StyleSpinner"
app:layout_constraintEnd_toEndOf="#+id/edtAddressAccount"
app:layout_constraintStart_toStartOf="#+id/textView14"
app:layout_constraintTop_toBottomOf="#+id/textView14" />
<include
android:id="#+id/textView14"
layout="#layout/include_text_require"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_12sdp"
app:layout_constraintStart_toStartOf="#+id/edtAddressAccount"
app:layout_constraintTop_toBottomOf="#+id/edtAddressAccount" />
<EditText
android:id="#+id/edtDistrict"
style="#style/StyleEditText"
android:autofillHints=""
android:ems="10"
android:inputType="textPersonName"
android:singleLine="true"
android:nextFocusUp="#+id/edtAddressAccount"
android:nextFocusLeft="#id/edtAddressAccount"
app:layout_constraintEnd_toEndOf="#+id/liner2"
app:layout_constraintStart_toStartOf="#+id/textView12"
app:layout_constraintTop_toBottomOf="#+id/textView12" />
...more view
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
I'm testing the use of Snackbar for the first time and I'm finding a behaviour which I don't understand. My Activity is composed of a Fragment, which is composed of a FrameLayout with a RecyclerView. I'm using Toolbar and Appbar.
When the Snackbar appears it moves the recyclerView up, I don't want it to behave like this, I want the Snackbar to show OVER the RecyclerView without moving it. I can however remove this from the Layout that contains the fragment:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
and then the Snackbar displays as I intend it to but of course my fragment overlaps with the Toolbar. I'm new to CoordinatorLayout so I fail to see how to get the behaviour I want. My full code is below.
My activity:
<? xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/master_coordinator_layout"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:animateLayoutChanges="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/toolbar_home"
layout="#layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="#+id/randomizerFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<FrameLayout
android:id="#+id/randomizerScreenFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
</FrameLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/randomizeFAB"
android:src="#drawable/ic_play_arrow_white_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
app:backgroundTint="#color/myYellow"
app:fabSize="normal"
app:layout_anchor="#id/randomizerFragment"
android:scaleType="center"
app:layout_anchorGravity="top|right"
android:visibility="invisible" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/resetFAB"
android:src="#drawable/ic_replay_white_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="60dp"
app:backgroundTint="#color/myOrange"
app:fabSize="mini"
app:layout_anchor="#id/randomizerScreenFragment"
android:scaleType="center"
app:layout_anchorGravity="top|right"
android:visibility="invisible" />
</android.support.design.widget.CoordinatorLayout>
My fragment:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
tools:context=".RandomizerActivity"
android:orientation="vertical"
android:animateLayoutChanges="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/factionsRecyclerView"
android:paddingTop="#dimen/margin_small"
android:layout_width="match_parent"
android:clipToPadding="false"
android:layout_height="wrap_content"/>
</LinearLayout>
I'm using the Snack like thus, fL being the FrameLayout #+id/randomizerFragment.
Snackbar.make(fL, "hey!", Snackbar.LENGTH_SHORT).show();
Any help is welcome.