I want to create a scrollview but only in the upper part above my button. But my image shows below my button and I want it to stop above my button and I should scroll. I assign the image in my code, maybe this can be the issue.
Code of my xml file:
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/show_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:autoSizeTextType="uniform"/>
<TextView
android:id="#+id/show_startdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:autoSizeTextType="uniform"/>
<TextView
android:id="#+id/show_enddate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:autoSizeTextType="uniform"/>
<ImageView
android:id="#+id/show_image_war"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/cancel_show_war"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/mybutton"
android:text="#string/cancel_input"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
</RelativeLayout>
Code where I assign my image:
File img_file = new File(imgPath);
ImageView imgView = findViewById(R.id.show_image_war);
imgView.setImageURI(Uri.fromFile(img_file));
Related
I have used card view as a row item in my recycler view and every cardview has different background color.
I've done it successfully until i add corner radius in my cardview. Now it is displaying some white layout in the middle.
Here is the code for my cardView.
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="5dp"
android:id="#+id/cvNB"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/txtNBHead"
android:layout_weight="0.9"
android:textSize="24sp"
android:fontFamily="#font/raleway_semibold"
android:textColor="#color/colorPrimary"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/NBOptions"
android:src="#drawable/ic_menu_icon_white_24dp"
android:layout_weight="0.1"/>
</LinearLayout>
<TextView
android:id="#+id/txtNBStory1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway_thin"
android:textSize="18sp"
android:textColor="#color/colorPrimary"
android:layout_margin="2dp"/>
<TextView
android:id="#+id/txtNBStory2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway_thin"
android:textSize="18sp"
android:textColor="#color/colorPrimary"
android:layout_margin="2dp"/>
<TextView
android:id="#+id/txtNBStory3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway_thin"
android:textSize="18sp"
android:textColor="#color/colorPrimary"
android:layout_margin="2dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
I am using it in recycler view with different background colors shown in below code
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
holder.cvNB.getBackground().setAlpha(0);
} else {
holder.cvNB.setCardBackgroundColor(ContextCompat.getColor(context, colors[index]));
}
here is what i am getting
Cardview displaying white section
I am really frustrated please help me out
Here is the code for recycler view layout
<RelativeLayout 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/listMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"/>
</ScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fabAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:src="#drawable/icon_add"
app:backgroundTint="#color/colorProfileText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listNBAnim"
app:lottie_fileName="nb_loading_anim.json"
app:lottie_loop="true"
android:visibility="gone"
app:lottie_autoPlay="true"/>
</RelativeLayout>
I need windowSoftInputMode= adjustRezise for my layout so that my buttons go up with the keyboard. BUT I don't want my BottomNagivationView to be affected by this.
How can I solve such?
My BottomNavigationView comes from MainActivity.xml which is:
<RelativeLayout
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"
tools:context=".MainActivity">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_navigation"></FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_menu"/>
</RelativeLayout>
My manifest has android:windowSoftInputMode="adjustPan" but I adjust it by code when I open the fragment with:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Here are some pictures so you could understand what I mean: https://imgur.com/a/vjePxI6
So what I would like to know is how I could set the BottomNavigationView to do nothing on keyboard opening while I'd like my buttons to be affected by :
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
In my case problem solved by just adding following line in manifest file.
android:windowSoftInputMode="adjustResize|adjustPan"
add android:windowSoftInputMode="adjustPan" inside your activity tag into your manifest file.
then go to your activity and change the parent layout to RelativeLayout, then create your FrameLayout which holds your fragments inside your relative layout which is your parent layout. Then add your second layout which is LinearLayout that holds the bottomNavigationView and make its Height and width match_parent but below the FrameLayout.
Below is the example of the main activity layout
<?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:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
//FrameLayout which holds all your fragments
<FrameLayout
android:id="#+id/fragments_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
//BottomNavigationView Container
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:layout_below="#id/fragments_container">
//BottomMenus
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="#+id/bottom_navigation"
android:background="#drawable/rectangle_4_dash"
android:layout_alignParentBottom="true">
//Container of Menus
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="5">
//BottomMenu One
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/home_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Home" />
</LinearLayout>
//BottomMenu Two
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/contact_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Contact" />
</LinearLayout>
//BottomMenu Three
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/about_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:layout_gravity="center"/>
</LinearLayout>
//BottomMenu Four
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="17dp"
android:layout_gravity="center"
android:src="#drawable/services_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</com.google.android.material.bottomnavigation.BottomNavigationView>
</LinearLayout>
Then go to your fragment which you want to scroll and design it like below one.
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Title Of Your Form"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/f_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/m_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/l_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Message"
android:inputType="text"
android:padding="10dp"
android:textSize="14sp" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="Send Messagge"
android:textAllCaps="false"
android:textColor="#color/white"
android:layout_marginBottom="40dp"/>
</LinearLayout>
</ScrollView>
That is how i solved it,
if you have any doubt please let me know but if its helps or looks like a correct answer please mark it as a correct answer thanks.
I'm making a fragment with a horizontal scroll on the previous screen.
the HorizontalScrollView is in a fragment
it worked fine when it was an activity but when you change it to a fragment the interface gets stuck
I have a HorizontalScrollView inside my ViewPager.
but when putting it in a fragment the interface does not work as it should, but at the moment of moving the view to the right or left it remains as the image
Like shown in Image below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/FragmentoLayout_fonemasTar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<HorizontalScrollView
android:id="#+id/horizontalScrollView1Tar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/secondary_text_light"
android:fadeScrollbars="false"
android:scrollbarSize="2dp"
android:scrollbarThumbHorizontal="#drawable/border_scroll_listview">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarCampo1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarCampo1" />
</LinearLayout>
<LinearLayout
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarCampo2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarCampo2" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarCampo3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarCampo3" />
</LinearLayout>
<LinearLayout
android:layout_width="30dp"
android:layout_height="wrap_content">
<TextView
android:id="#+id/lblEspacio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_FormatoTar_txtTarSubCampo3" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarSubCampo3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarSubCampo345" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarCampo4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarCampo4" />
</LinearLayout>
<LinearLayout
android:layout_width="30dp"
android:layout_height="wrap_content">
<TextView
android:id="#+id/lblEspacio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_FormatoTar_txtTarSubCampo4" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarSubCampo4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarSubCampo345" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarCampo5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarCampo5" />
</LinearLayout>
<LinearLayout
android:layout_width="30dp"
android:layout_height="wrap_content">
<TextView
android:id="#+id/lblEspacio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_FormatoTar_txtTarSubCampo5" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="#+id/lblTarSubCampo5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LayoutTar_lblTarSubCampo345" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ListView
android:id="#+id/lst_PuntoArtFon1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:scrollbarThumbVertical="#drawable/border_scroll_listview"
tools:listitem="#layout/formato_tar_layout"></ListView>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
make background color:white, and clickable = true. This will solve your problem
This is happening because the new view that you are loading(by swiping right/left) is above the HorizontalScrollView & its background colour is transparent. You must give a white background colour to the parent LinearLayout of all the fragments.
Also set android:clickable to true so that the touch events don't trigger the previous fragments.
Make background color: white, and click event as true. This may solve your issue
I have a project with Android Studio and in Activity I have content html using WebView. The Image should be shown as an ImageView to make it look good. I want to change the height of the ImageView when I scroll the WebView to the bottom and then back to normal size when I scroll back to the top. How can enable it?
Here is my xml code:
<?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="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:background="#ffffff"
android:orientation="vertical"
tools:context="com.demowordpress.app.DetailActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="220dp">
<ImageView
android:id="#+id/imageView"
android:scaleType="center"
android:layout_width="match_parent"
android:layout_height="220dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<TextView
android:padding="10dp"
android:id="#+id/textView"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:ellipsize="end"
android:maxEms="10"
android:maxLines="3"
android:background="#android:drawable/screen_background_dark_transparent"
android:textAppearance="#style/TextAppearance.AppCompat.Title" />
</LinearLayout>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/wv"
android:scrollbars="none"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:visibility="gone">
</WebView>
<ProgressBar
android:id="#+id/pBar"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<Button
android:id="#+id/Button"
android:layout_width="80dp"
android:layout_height="80dp"
android:focusable="true"
android:clickable="true"
android:visibility="gone"
android:drawableTop="#drawable/ic_retry"
android:text="try Again"
android:textColor="#color/colorPrimary"
android:background="#android:color/transparent"
android:layout_gravity="center"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/white"
android:clickable="true"
ads:srcCompat="#drawable/ic_share"
app:backgroundTint="#color/white"
android:layout_gravity="end|bottom"
android:layout_marginBottom="50dp"
android:layout_marginRight="40dp"
/>
</FrameLayout>
</LinearLayout>
How to add Floating Action Button from the support library for CardView so that when you scroll through the ScrollView, the button has gone up along with the card?
My app
before scrolling
after scrolling
The button should go along with the card
I want to fix this
Layout
<?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"
>
<ScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white_vk_background_color">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/spacing_8"
android:orientation="vertical"
android:padding="#dimen/spacing_16">
<android.support.v7.widget.CardView
android:id="#+id/behavior_card_view"
style="#style/RateCardView"
app:cardBackgroundColor="#color/white"
app:cardCornerRadius="#dimen/spacing_2"
app:cardElevation="#dimen/spacing_8">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="#dimen/spacing_16"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="#dimen/spacing_8">
<TextView
android:id="#+id/description_rate_usd_text_view"
style="#style/AppTextView.RateTextView"
android:text="#string/description_currency_text_view_usd"/>
<TextView
android:id="#+id/rate_usd_text_view"
style="#style/AppTextView.RateTextView"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#id/description_rate_usd_text_view"
tools:text="63.99"
/>
<TextView
android:id="#+id/rate_difference_usd_text_view"
style="#style/AppTextView.DifferenceTextView"
android:layout_toRightOf="#id/rate_usd_text_view"
tools:text="+0.44"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="#dimen/spacing_8">
<TextView
android:id="#+id/description_rate_eur_text_view"
style="#style/AppTextView.RateTextView"
android:text="#string/description_currency_text_view_eur"/>
<TextView
android:id="#+id/rate_eur_text_view"
style="#style/AppTextView.RateTextView"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#id/description_rate_eur_text_view"
tools:text="71.99"
/>
<TextView
android:id="#+id/rate_difference_eur_text_view"
style="#style/AppTextView.DifferenceTextView"
android:layout_toRightOf="#id/rate_eur_text_view"
tools:text="+0.15"/>
</RelativeLayout>
<TextView
android:id="#+id/rate_update_time_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_marginBottom="#dimen/spacing_8"
android:layout_marginLeft="#dimen/spacing_16"
android:layout_marginTop="#dimen/spacing_16"
android:gravity="center"
android:textSize="#dimen/density_font_size_text_date"
tools:text="Date: 15.07.2016"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/converter_card_view"
style="#style/RateCardView"
app:cardBackgroundColor="#color/white"
app:cardCornerRadius="#dimen/spacing_2"
app:cardElevation="#dimen/spacing_8">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/spacing_16">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/converter_ruble_edit_text"
style="#style/RateEditText"
android:hint="#string/description_currency_ruble"
app:met_baseColor="#android:color/black"
app:met_bottomTextSize="#dimen/density_font_size_text_converter"
app:met_errorColor="#color/red_light"
app:met_floatingLabel="normal"
app:met_floatingLabelAlwaysShown="true"
app:met_floatingLabelTextSize="#dimen/density_font_size_text_converter"
app:met_helperText=""
app:met_primaryColor="#color/red_light"
app:met_textColorHint="#android:color/transparent"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/converter_dollar_edit_text"
style="#style/RateEditText"
android:hint="#string/description_currency_dollar"
app:met_baseColor="#android:color/black"
app:met_bottomTextSize="#dimen/density_font_size_text_converter"
app:met_errorColor="#color/red_light"
app:met_floatingLabel="normal"
app:met_floatingLabelAlwaysShown="true"
app:met_floatingLabelTextSize="#dimen/density_font_size_text_converter"
app:met_helperText=""
app:met_primaryColor="#color/red_light"
app:met_textColorHint="#android:color/transparent"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/converter_euro_edit_text"
style="#style/RateEditText"
android:hint="#string/description_currency_euro"
app:met_baseColor="#android:color/black"
app:met_bottomTextSize="#dimen/density_font_size_text_converter"
app:met_errorColor="#color/red_light"
app:met_floatingLabel="normal"
app:met_floatingLabelAlwaysShown="true"
app:met_floatingLabelTextSize="#dimen/density_font_size_text_converter"
app:met_helperText=""
app:met_primaryColor="#color/red_light"
app:met_textColorHint="#android:color/transparent"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/update_floating_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/density_spacing_size_floating_action_button"
android:layout_marginRight="#dimen/float_action_button_spacing_8"
android:src="#drawable/ic_cached_white_24dp"
app:fabSize="mini"
app:layout_anchor="#id/behavior_card_view"
app:pressedTranslationZ="6dp"
app:layout_anchorGravity="end|right|center"
/>
</android.support.design.widget.CoordinatorLayout>
Instead of anchoring to behavior_card_view, try anchoring it to something inside behavior_card_view. Ideally, anchor to the bottom of the USD textview. This should prevent the FAB from sliding down.
I would actually create a invisible layout which I can use to anchor but it doesn't affect the UI otherwise.
I can't replicate the issue you are having but the following works as you want:
<RelativeLayout
android:id="#+id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingRight="10dp">
<TextView
android:id="#+id/tv1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:paddingLeft="12dp"
android:text="Setting"
android:focusable="true"
android:focusableInTouchMode="true" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:src="#drawable/ic_add"
app:fabSize="mini"
app:pressedTranslationZ="6dp"
app:layout_anchorGravity="end|right|center"
app:layout_anchor="#id/tv1" />
... a lot of elements here ...
</RelativeLayout>
This RelativeLayout is the only element inside my ScrollView element.