Android Sliding Panel with Scrollview - scrollview

I'm trying to use a Sliding Panel from the link here and I'm facing the problem shown in the image:
My idea is to have custom content when the user swipes the bottom menu up, and have the possibility to scroll this content. But when the panel goes to anchored state, it seems like the content height is not set correctly, because some piece of the content doesn`t show up.
I downloaded the sample in the link above, and the problem already occurs. i made a minor change, adding the scrollview.
Am I missing something? any help would be much appreciated.
<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"
tools:context=".DemoActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:collapsedHeight="68dp"
sothree:dragView="#+id/name"
sothree:shadowHeight="4dp" >
<TextView
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:clickable="true"
android:focusable="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textSize="14sp" />
<Button
android:id="#+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical|right"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textSize="14sp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/slide_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/graphic" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="teste" />
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/graphic" />
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/graphic" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>

This problem occurs because the sliding view is fully measured and then placed partially off the screen. As you slide the view up, its size doesn't change, just its position. This means that the ScrollView isn't fully visible when anchored.
The solution I came up with is to use the PanelSlideListener events to resize the ScrollView as the position of the sliding view changes. Just give your ScrollView an ID of "#+id/scroll_view" and use this modified section of the onCreate() code below from the AndroidSlidingUpPanel demo app.
final float anchorPoint = 0.5f;
final ScrollView scrollView = (ScrollView) findViewById(R.id.scroll_view);
final SlidingUpPanelLayout layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
layout.setAnchorPoint(anchorPoint);
layout.setPanelSlideListener(new PanelSlideListener() {
#Override
public void onPanelSlide(View panel, float slideOffset) {
Log.i(TAG, "onPanelSlide, offset " + slideOffset);
setActionBarTranslation(layout.getCurrentParalaxOffset());
resizeScrollView(panel, slideOffset);
}
#Override
public void onPanelExpanded(View panel) {
Log.i(TAG, "onPanelExpanded");
resizeScrollView(panel, 0.0f);
}
#Override
public void onPanelCollapsed(View panel) {
Log.i(TAG, "onPanelCollapsed");
}
#Override
public void onPanelAnchored(View panel) {
Log.i(TAG, "onPanelAnchored");
resizeScrollView(panel, anchorPoint);
}
private void resizeScrollView(View panel, float slideOffset) {
// The scrollViewHeight calculation would need to change based on
// what views you have in your sliding panel. The calculation below
// works because your layout has 2 child views.
// 1) The row with the drag view which is layout.getPanelHeight() high.
// 2) The ScrollView.
final int scrollViewHeight =
(int) ((panel.getHeight() - layout.getPanelHeight()) * (1.0f - slideOffset));
scrollView.setLayoutParams(
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
scrollViewHeight));
}
});

Related

SimpleCallback for dragging view is not working, when i try to move top to bottom and bottom to top dragging item with ItemTouchHelper

my RecyclerView scrolls not working top to bottom and bottom to top when i try to dragging. You can see the below code
i'm using xml like this
`
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvDraggable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dp_16"
android:layout_marginEnd="#dimen/dp_16"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardViewSeatWise" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
`
I got a solution:
So the issues was that my layout
If you are using NestedScrollView just remove and instead of using other layouts use ConstraintLayout
Steps:
Use ConstrainLayout and RecylerView like this:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvDraggable"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_0"
android:layout_marginStart="#dimen/dp_16"
android:layout_marginEnd="#dimen/dp_16"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Note- you can also try to use:
viewBinding.recycler.setHasFixedSize(true)
If you are using notifyDataSetChanged() so just replace it by notifyItemMoved() in onMove() method

React Native: VideoView android native module spilling out of the container

Video view spilling to the previous view
I have a scrollview and inside the scrollview I have bunch of videos. I have created a native video module for android using VideoView class and following are code to resize the video.
public class CustomVideoLayout extends RelativeLayout {
private ThemedReactContext mThemedReactContext;
private RelativeLayout screenLayout;
private CustomVideoView videoView;
private ImageView imageView;
private ImageButton playPauseButton;
private ImageButton muteButton;
private boolean mMuted;
private boolean mRepeat;
private boolean mEnableControls;
private MediaPlayer mediaPlayer;
public CustomVideoLayout(#NonNull ThemedReactContext context, Activity activity) {
super(context);
mThemedReactContext = context;
screenLayout = (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.layOutName, null);
this.addView(screenLayout);
imageView = findViewById(R.id.posterImage);
videoView = findViewById(R.id.customVideoView);
videoView.setOnPreparedListener(preparedListener);
videoView.setOnTouchListener(videoViewOnTouchListener);
videoView.setOnCompletionListener(videoOnCompleteHandler);
playPauseButton = findViewById(R.id.pause_play_button);
playPauseButton.setOnClickListener(onClickListener);
muteButton = findViewById(R.id.volume_button);
muteButton.setOnClickListener(onClickListener);
}
// ......
}
If i'm not resizing the height, the video is not spilling up and also its changing it's original aspect ratio. But in order to maintain the original aspect ratio i must recalculate the height and width. And when the height is exceeding the container's height, its spilling a portion of the video on the previous VideoView.
Note: The top video is not spilling at all when put on top.
Following is the Layout file.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="#+id/video_wrapper">
<com.videoplayer.CustomVideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:id="#+id/customVideoView"/>
<ImageView
android:id="#+id/posterImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bg_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageButton
android:id="#+id/pause_play_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/pause"
android:scaleType="fitXY"
android:tag="#drawable/pause"
android:visibility="invisible"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/volume_button"
android:background="#drawable/volume"
android:scaleType="fitXY"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:tag="#drawable/volume"
android:visibility="invisible"/>
</RelativeLayout>
</FrameLayout>

Hopefully a simple Kotlin regarding looping through a recycler

I have a recycler in my activity for acrostic poetry. The recycler displays an image of the letters of the word (Stone Age, in this case) and an EditText to enter the acrostic words. What I want to do is read the words that have been entered, so for "Stone Age" I'm creating 8 items in the recycler.
In order to get the words, I have tried to replicate the steps in this question How to iterate over RecyclerView items. I think I'm close, but I can't quite get over the line.
I have this function where I am trying to read the values (at this stage just into the logcat)
I figured that getChildCount returned the items, but this is logging 2 (or sometimes, oddly, 3) rather than the 8 I would expect, so I'm struggling to understand what I am looping.
private fun saveTask() {
var p: String = ""
Log.d(HWG.TAG, "Children: ${acrosticRecycler.getChildCount().toString()}")
for (i in 0 until acrosticRecycler.getChildCount()) {
var holder: AcrosticAdapter.ViewHolder
if(acrosticRecycler.findViewHolderForAdapterPosition(i) != null) {
holder = acrosticRecycler.findViewHolderForAdapterPosition(i) as AcrosticAdapter.ViewHolder
p = holder.txtWord.text.toString()
Log.d(HWG.TAG, "Word: ${p}")
}
}
}
This is the layout of the recycler
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="4dp"
app:cardElevation="6dp">
<LinearLayout
android:id="#+id/llTaskList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/imgLetter"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="centerCrop"
app:srcCompat="#drawable/icons8_s" />
<EditText
android:id="#+id/txtWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:hint="Stone Age"
android:textAllCaps="true"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
This is the activity in which the recycler sits
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/background"
tools:context=".TextualTask">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="24dp"
android:background="#color/background"
app:cardCornerRadius="4dp"
app:cardElevation="6dp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="24dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/subjectImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="centerCrop"
app:srcCompat="#drawable/icons8_knowledge_sharing_80" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="15dp"
android:text="Acrostic Poem"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_margin="6dp"
android:background="?android:attr/listDivider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/txtPreamble"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="15dp"
android:text="Preamble text"
android:textAlignment="center"
android:textSize="14sp"
android:textStyle="bold|italic" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<androidx.cardview.widget.CardView
android:id="#+id/crdWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="24dp"
app:cardBackgroundColor="#color/cardback"
app:cardCornerRadius="4dp"
app:cardElevation="6dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:backgroundTint="#color/start"
android:text="Submit" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/acrosticRecycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:itemCount="5"
tools:listitem="#layout/acrostic_task" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Oddly enough, sometime the for loop gets the values from items 0-2, but sometimes it doesn't. The call to saveTask is made from btnSubmit as I don't need to get the values at the point the user enters them, just when they're happy to submit.
Could someone point me in the right direction please?
You can't get the correct count from acrosticRecycler.getChildCount().
because acrosticRecycler.getChildCount() will return the count of currently showed item in the RecyclerView. So even if your data is 8, but the showed data in the screen is only 3 items. So you will always get 3 not 8.
It's not good practice to get the data from the ViewHolder in recycler view directly. You should get the data from the list you have inserted to recycler view adapter.
for example, you can create adapter like this :
class AcrosticAdapter(var listData: ArrayList<AcrosticPoetry>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun getItemCount(): Int = listData.size
}
//assuming this is your model class
class AcrosticPoetry() {
var textWord = ""
}
and you can change your code to
private fun saveTask() {
val adapter = acrosticRecycler.adapter as AcrosticAdapter
val data = adapter.listData
for (i in 0 until data.size) {
val word = data[i].txtWord
Log.d(HWG.TAG, "Word: ${word}")
}
}

CollapsingToolbarLayout not Collapsing with RecyclerView Scroll Behavior

I have a CollapsingToolbarLayout that shows an image (placed inside the ConstraintLayout to keep the ratio 1:1) and a RecyclerView that has the com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior attached to it.
Image of Layout
The image is in green and the RecyclerView is in blue.
The problem is when I scroll up on the RecyclerView, the CollapsingToolbarLayout doesn't collapse. Instead, the RecyclerView just scrolls underneath the entire layout. I have to manually scroll inside the CollapsingToolbarLayout for it to collapse.
Here is the code for the layout:
<androidx.coordinatorlayout.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">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:src="#drawable/ic_launcher_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent"
android:nestedScrollingEnabled="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/fab_margin"
app:layout_anchor="#id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="#android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I originally had the RecyclerView inside a NestedScrollView with the scrolling behavior attached to the NestedScrollView, but this was causing issues with the Adapter creating a ViewHolder object for EVERY single item in the RecyclerView and that was causing a lot of performance and lagging/freezing issues.
From my understanding, a RecyclerView should not be placed inside a NestedScrollView for this reason and that is why I took the NestedScrollView out.
Any help would be appreciated!
Simply you should disable nested scrolling in recycler view
android:nestedScrollingEnabled="false"
Also, if you have nested recycler views you should disable nested scrolling in child recycler views.
If you want the image to collapse when recyclerview scrolls, use this scroll flags
app:layout_scrollFlags="scroll|snap|enterAlwaysCollapsed"
and use
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
in your recyclerview , and android:nestedScrollingEnabled attribute is not required for what you want to achieve.
have you looked into https://www.journaldev.com/13927/android-collapsingtoolbarlayout-example
Also see some of the things you are missing

android, how to place a scroll view in the middle of the screen:

I'm trying to create a a screen layout of the following though:
A line with some TextView in it
A scroll view where the user actions will add or remove View from
A buttons line.
I have no problem with 1. or 3. But 2. gives me troubles. My scheme is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainX"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/labels"
android:layout_weight="1">
<!--Some text view of various sizes -->
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dataScroll">
<LinearLayout
android:id="#+id/dataShow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttons"
android:layout_weight="1">
<!--some buttons-->
</LinearLayout>
</LinearLayout>
When I run the program, the buttons line is in the middle of the screen and When I add element to the screen (using the addView on the dataShow layout), the frist one is added without a problem but after that I can't tell what is happening.
Thanks
I'm not exactly sure what you are trying to do.
It seems like you want to dynamically add items to the dataShow layout. Instead of using a ScrollView containing a LinearLayout, you should be using a ListView (vertical scrolling) or Gallery (horizontal scrolling) for your dataShow layout. This will provide the scroll functionality and allow you to add items dynamically to the list/gallery.
Try using a RelativeLayout, then align the header at the top, and the footer at the bottom. Set the ScrollView paddingBottom.
<?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">
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="text"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/header"
android:layout_above="#+id/footer"
android:paddingBottom="100dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="center main content"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#color/colorPrimary"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
</RelativeLayout>