I am using coardinate layout with recyclerview in viewpager and tablayout. I have a view for banner which i want to show over the recyclerview at the bottom. This bottom view is only visible if i scroll up the recyclerview list and hides when i scrollback down.I want this view to be visible all the time over recyclerview. Any help will be appreciated. Thanks in advance.r image description here]1]1
Here is my xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/deal_display_bg"
tools:context="com.safar.spicedeals_activities.DealsActivity$PlaceholderFragment">
<View
android:id="#+id/topview_deal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentTop="true"
android:background="#color/spice_laddooblue"
android:visibility="gone" />
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="#+id/no_deals_available"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/no_deals_available"
android:textColor="#color/spice_laddooblue"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="gone" />
<FrameLayout
android:id="#+id/frameLayoutDeals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bannerView"
android:layout_below="#+id/topview_deal"
android:padding="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:id="#+id/progressBarDeals"
style="?android:attr/android:progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- </android.support.v4.widget.SwipeRefreshLayout> -->
</FrameLayout>
<RelativeLayout
android:id="#+id/relativeLayout_PriceTotal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/background_with_border_square"
android:padding="10dp"
android:visibility="gone">
<TextView
android:id="#+id/textView_totalPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/total_price"
android:textColor="#color/spice_laddooblue"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_totalPriceResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignTop="#+id/textView_totalPrice"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="#+id/textView_totalPrice"
android:textColor="#color/spice_laddooblue"
android:textSize="15sp"
android:textStyle="bold" />
<Button
android:id="#+id/button_processDeal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_totalPrice"
android:layout_marginTop="10dp"
android:background="#color/spice_laddooblue"
android:text="#string/proceed_tag"
android:textColor="#color/White"
android:textStyle="italic" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bannerView"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#drawable/curved_white_with_blue_border"
android:visibility="gone">
<TextView
android:id="#+id/bannerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="3dp"
android:text="Banner"
android:visibility="gone" />
<ImageView
android:id="#+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="3dp"
android:scaleType="fitXY"
android:visibility="gone" />
<ImageView
android:id="#+id/bannerClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:src="#drawable/cross_icon" />
</RelativeLayout>
</RelativeLayout>
This worked for me! add this attribute for your android.support.v7.widget.Toolbar
app:layout_scrollFlags="scroll"
The app:layout_scrollFlags attribute of the Toolbar indicates to the view how to respond. It has the following possible values.
scroll :
This flag is generally set for all views that need to
scroll off-screen. Views that don’t use this flag remain static
allowing the other scrollable views to slide behind it.
enterAlways :
This flag ensures that any downward scroll will cause the view to
become visible, enabling the quick return pattern.
enterAlwaysCollapsed :
An additional flag for ‘enterAlways’ which
modifies the returning view to only initially scroll back to it’s
collapsed height.
exitUntilCollapsed :
This flag causes the view to
be scrolled until it is collapsed (its minHeight is reached) before
exiting
snap : Upon a scroll ending, if the view is only partially
visible then it will be snapped and scrolled to it’s closest edge.
Hence this avoids mid-animation states of a view
More details can be found here.
Related
I have 2 views (a button and a slider bar), one above the other, and I am animating the lower one out of frame and I want the other view to also animate down the same amount. My issue is that the spot where the lower view use to be clips out the top view. (See images). Both animations are triggered by a view model property change.
TimeView.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height);
MyPositionButton.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height);
Before Animation:
After Animation:
How do I get the lower view to stop clipping the upper one? I have attempted to alter the view's Z and TransitionZ properties to make sure the button is higher then the bar. I have also tried to set the visibility of the bar to Gone on animation completion. Also I have tried to use a TranslateAnimation so that I could have control over the Fill properties. None of these thing have worked.
Here is a look at the axml.
<RelativeLayout
android:id="#+id/map_area_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#id/under_list_view">
<RelativeLayout
android:id="#+id/map_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="#+id/time_view"
android:layout_width="300dp"
android:layout_height="44dp"
android:background="#ddffffff"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/time_text_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="4:56PM"
android:textColor="#color/gray_dark"
android:textSize="18dp"
android:gravity="center_vertical"
android:layout_marginLeft="10dp" />
<SeekBar
android:id="#+id/time_seek_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:max="1440"
android:progress="700"
android:progressDrawable="#drawable/custom_scrubber_progress"
android:thumb="#drawable/custom_scrubber_control"
android:secondaryProgress="0"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/time_text_view" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/time_view"
android:layout_alignParentLeft="true"
android:layout_margin="5dp">
<ImageButton
android:id="#+id/my_location_button"
android:layout_height="50dp"
android:layout_width="50dp"
android:background="#drawable/ek_fab_button_ripple_white"
android:src="#drawable/ic_my_location_24p"
android:tint="#color/gray_dark" />
</RelativeLayout>
</RelativeLayout>
After switching on the "Show layout bounds", OP found out that he was animating the Button itself, not the RelativeLayout. After animating RelativeLayout no clipping would happen.
Old answer
Change the places of your RelativeLayouts, so that one with ImageButton is declared below of another with SeekBar. In that case the ImageButton will be drawn over SeekBar.
<RelativeLayout
android:id="#+id/map_area_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#id/under_list_view">
<RelativeLayout
android:id="#+id/map_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="#+id/time_view"
android:layout_width="300dp"
android:layout_height="44dp"
android:background="#ddffffff"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/time_text_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="4:56PM"
android:textColor="#color/gray_dark"
android:textSize="18dp"
android:gravity="center_vertical"
android:layout_marginLeft="10dp" />
<SeekBar
android:id="#+id/time_seek_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:max="1440"
android:progress="700"
android:progressDrawable="#drawable/custom_scrubber_progress"
android:thumb="#drawable/custom_scrubber_control"
android:secondaryProgress="0"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/time_text_view" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/time_view"
android:layout_alignParentLeft="true"
android:layout_margin="5dp">
<ImageButton
android:id="#+id/my_location_button"
android:layout_height="50dp"
android:layout_width="50dp"
android:background="#drawable/ek_fab_button_ripple_white"
android:src="#drawable/ic_my_location_24p"
android:tint="#color/gray_dark" />
</RelativeLayout>
</RelativeLayout>
I have an EdiText at the bottom of my layout.The issue I was having is that when it gets focus the screen shifts upwards to give space to soft keyboard.To resolve it I added
android:windowSoftInputMode="adjustResize"
inside my Activity declaration in manifest.Now the problem is that the edittext hides behind the softkeyboard although screen doesn't shifts.
If instead I put
android:windowSoftInputMode="adjustPan"
then the activity's main window shifts upward which i don't want.
How can i resolve this in such way that when EdiText gets focus activity's main window does NOT shift upwards to make room for the soft keyboard but the main window is resized including the EdiText so that keyboard comes below EdiText as seen in many apps.
Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_feed">
<ProgressBar
android:id="#+id/progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center_vertical" />
<ListView
android:id="#+id/comments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F7F7F7"
android:paddingTop="10dp"
android:layout_above="#+id/border_view_comment"
android:divider="#android:color/transparent"
android:dividerHeight="10dp"
android:paddingBottom="10dp"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay" />
<TextView
android:id="#+id/empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/no_comment_msg"
android:visibility="gone"/>
<View
android:id="#+id/border_view_comment"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="#+id/commentlayout"
android:background="#C7C7C7"
android:visibility="gone"/>
<RelativeLayout
android:id="#+id/commentlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/comment_box_shadow"
android:padding="10dp">
<ImageView
android:id="#+id/commentor_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="15dp"
/>
<ImageView
android:id="#+id/clickPostComment"
android:layout_width="30dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:src="#drawable/post"
android:textColor="#color/white" />
<EditText
android:id="#+id/commentsPost"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignTop="#id/commentor_image"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#id/clickPostComment"
android:layout_toRightOf="#id/commentor_image"
android:background="#drawable/comment_edittext_bg"
android:hint="Comments"
android:singleLine="true"
android:maxLength="140"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#color/title_gray"
android:textColorHint="#d5d5d5"
android:textSize="15sp" />
<ImageView
android:layout_width="25dp"
android:layout_height="30dp"
android:layout_alignTop="#id/commentsPost"
android:layout_marginLeft="10dp"
android:layout_marginRight="-2dp"
android:layout_toLeftOf="#id/commentsPost"
android:scaleType="fitStart"
android:src="#drawable/comment_shape" />
</RelativeLayout>
</RelativeLayout>
make your view scrollable by embed your view inside Scrollview
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
.....
add your layout
......
</ScrollView>
If that doesn't help make you root layout as RelativeLayout and design your layout with RelativeLayout
This is sort of a continuation of , where I wanted to get a warning text at the bottom of my screen (below my bottom tool bar) when off line. When in offline mode looks correct:
However when I hide the offline mode it pops to the top of the layout, like such (hiding everything I want to show):
I tried setting the bottom tool bar to android:layout_alignParentBottom="true", that does keep it from popping to the top when I hide the RelativeLayout with the TextView in it (Offline Mode) but then they overlay each other when I do not hide the Offline Mode.
Probably easy for someone a bit more experienced with Android UI than I. The XML layout currently looks like this:
<RelativeLayout
android:id="#+id/mainLyt"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/formScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="#+id/bottomBar" >
<LinearLayout
android:id="#+id/formLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="15dp"
android:paddingRight="10dp"
android:paddingBottom="15dp"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/bottomBar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_above="#+id/bottomOffline"
android:background="#color/form_toolbar">
<ImageButton
android:id="#+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="btnPrevClicked"
android:layout_alignParentLeft="true"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_prev"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnIndex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/btnPrev"
android:onClick="btnIndexClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_index"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnValidation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/btnIndex"
android:onClick="btnValidationClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_validate"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="btnNextClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_next"
android:padding ="8dp"
/>
<!-- Some Buttons -->
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottomOffline"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_alignParentBottom="true"
android:background="#color/orangelight"
android:gravity="center_horizontal">
<TextView
android:id="#+id/offline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:text="OFFLINE MODE"
android:textStyle="bold"
android:textColor="#color/white"
android:padding ="8dp"
/>
</RelativeLayout>
</RelativeLayout>
Thanks!
Try wrapping the bottom views in a LinearLayout and remove the align fields from the two nested views
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/bottomBar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#color/form_toolbar">
<ImageButton
android:id="#+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="btnPrevClicked"
android:layout_alignParentLeft="true"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_prev"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnIndex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/btnPrev"
android:onClick="btnIndexClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_index"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnValidation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/btnIndex"
android:onClick="btnValidationClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_validate"
android:padding ="8dp"
/>
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="btnNextClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="#drawable/toolbar_next"
android:padding ="8dp"
/>
<!-- Some Buttons -->
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottomOffline"
android:layout_width="match_parent"
android:layout_height="34dp"
android:background="#color/orangelight"
android:gravity="center_horizontal">
<TextView
android:id="#+id/offline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:text="OFFLINE MODE"
android:textStyle="bold"
android:textColor="#color/white"
android:padding ="8dp"
/>
</RelativeLayout>
Using Java, we can programatically set the view to align at the bottom when you're in online mode. The following could should be placed after the code that you use to remove the offline bar. (Since you didn't post your Java, I can't be more specific) I've assumed that the variable bottomBar is of type RelativeLayout and assigned through findViewById(R.id.bottomBar.
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)bottomBar.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
bottomBar.setLayoutParams(params);
What this should do is set the ALIGN_PARENT_BOTTOM flag (android:layout_alignParentBottom="true" in XML) on the bottom bar so that it will stay at the bottom, even after the offline bar is removed. So, if you add that immediately after removing the offline bar, it will update the view and show the bar properly
I have a layout for a listview item and it's displayed incorrectly (book descr goes over the last update date). Can you please help me to fix?
If I set
android:layout_above="#+id/lastUpdatedDt"
to the bookDescr item the whole text disappears...
EDIT: I've updated sample according to comments
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:layout_margin="10dp"
android:background="#drawable/big_card_details"
android:clickable="true"
android:focusable="false">
<CheckBox
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/starStyle"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="10dp" />
<TextView
android:id="#+id/bookTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Book title"
android:textSize="16sp"
android:layout_alignBaseline="#id/icon"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/icon" />
<TextView
android:id="#+id/bookSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="470k"
android:layout_alignBaseline="#id/icon"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
<TextView
android:id="#+id/lastUpdatedDt"
android:layout_width="match_parent"
android:layout_height="26dip"
android:singleLine="true"
android:text="Updated 27.04.2014 17.10"
android:textSize="12sp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#id/icon" />
<TextView
android:id="#+id/bookDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:textSize="10sp"
android:text="here should be long description"
android:layout_alignEnd="#id/bookSize"
android:layout_below="#+id/bookTitle"
android:layout_marginTop="20dp"
android:layout_alignLeft="#+id/icon" />
<!-- this is the button that will trigger sliding of the expandable view -->
<ImageButton
android:id="#+id/expand_details_button"
android:src="#drawable/slide_button_details"
android:layout_alignTop="#id/lastUpdatedDt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_alignBaseline="#id/lastUpdatedDt"
android:layout_alignParentBottom="true"
android:layout_alignRight="#id/bookSize"
android:layout_alignEnd="#id/bookSize" />
</RelativeLayout>
<!-- this is the expandable view that is initially hidden and will slide out when the more button is pressed -->
<LinearLayout
android:id="#+id/details_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
>
<!-- put whatever you want in the expandable view -->
<Button
android:layout_width="match_parent"
android:layout_weight="0.3"
android:drawableTop="#drawable/ic_action_read"
android:text="#string/ReadBook"
style="#style/SlideButtonTheme" />
<Button
android:layout_width="match_parent"
android:layout_weight="0.3"
android:drawableTop="#drawable/ic_action_open_browser"
style="#style/SlideButtonTheme"
android:text="#string/OpenInBrowser" />
</LinearLayout>
</LinearLayout>
Hope your aware that the child view in the RelativeLayout need to placed below/above any of the sibling views or aligned from the parent.
The problem here is that , lastUpdatedDt is aligned to parent bottom , since the parent RelativeLayout height is set to wrap_content height will be decided based on the child views , so that lastUpdatedDt is placed at the bottom depends on the parent height, which overlap the sibling view.
FIX : Just set the android:layout_below="#+id/bookDescription" for the lastUpdatedDt TextView , so that the lastUpdatedDt will always be placed bottom of the parent and below bookDescription TextView sibling.
I have a certain problem in my Activity. The ScrollView doesn't scroll down to the bottom.
I have a screenshot for you.
If you look at the scrollbar of the scrollView, you can see that it's not scrolling down to the bottom.
Here's my XML layout of the scrollView:
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:fillViewport="true"
android:layout_below="#+id/step2_header" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp" >
<TextView
android:id="#+id/step2_headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="#string/Schritt2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/dark_blue"
android:textStyle="bold|italic" />
<ImageView
android:id="#+id/step2_image"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_below="#+id/step2_headerText"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:src="#drawable/menu_leiste" />
<TextView
android:id="#+id/step2_infoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/step2_image"
android:text="#string/step2Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/step2_but1Img"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="#+id/step2_infoText"
android:layout_marginTop="10dp"
android:src="#drawable/menu_leiste_selector" />
<TextView
android:id="#+id/step2_but1Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/step2_but1Img"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/step2_but1Img"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="#string/step2But1Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white" />
<ImageView
android:id="#+id/step2_but1ArrowImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_alignBottom="#+id/step2_but1Img"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/step2_but1Img"
android:src="#drawable/location_web_site" />
<ImageView
android:id="#+id/step2_but2Img"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="#+id/step2_but1Img"
android:layout_marginTop="10dp"
android:src="#drawable/menu_leiste_selector" />
<TextView
android:id="#+id/step2_but2Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/step2_but2Img"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/step2_but2Img"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="#string/step2But2Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white" />
<ImageView
android:id="#+id/step2_but2ArrowImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_alignBottom="#+id/step2_but2Img"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/step2_but2Img"
android:src="#drawable/location_web_site" />
</RelativeLayout>
</ScrollView>
How can I fix it?
The problem is android:layout_margin="10dp" in RelativeLayout of SrcollView
Replace
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
with
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
use in scrollView xml
android:paddingBottom="10dp"
it'll shift content of scroll view to 10 dp upward not the VIEW.
Try NestedScrollView instead.
I have had this problem several times myself and while simply adding extra padding to the bottom to hide the fact that the scroll view is going 'behind' the bottom bar works, a better solution is to use a NestedScrollView as mentioned in this answer: https://stackoverflow.com/a/36871385/6573127
For me I have another specific solution if the parent layout of the ScrollView is ConstraintLayout. If so, we don't need to set the padding or margin.
<androidx.constraintlayout.widget.ConstraintLayout
....>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="<if there is any element before this this scrollview >">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
For me, setting explicit height to some of my internal elements helped.
I was suffering from the same problem. Try to add more padding to the bottom of scrollView.It works for me.
android:paddingBottom="50dp"
This may be problem with your layout design. if you add the margin for the view then it will be visible clearly. so
In scrollview add
android:layout_marginBottom="30dp"