I am a windows developer. I don't have much knowledge in android. So my scenario is like this: I have a scrollview which has its child as a linearlayout. The Linear layout has 3 listviews. I want to show all the items in all of the 3 listviews. The scrolling will be handled by the top level scrollview.
Will this work ?
<ScrollView
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView1"
android:fadeScrollbars="true">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linearLayout2">
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="#+id/linear_currentSubEmpty"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:background="#android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/currentListViewLayout"
android:layout_below="#+id/currentSubsView">
<com.fortysevendeg.swipelistview.SwipeListView xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="#+id/currentSubList"
android:listSelector="#00000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
swipe:swipeFrontView="#+id/front"
android:background="#android:color/transparent"
swipe:swipeBackView="#+id/back"
swipe:swipeDrawableChecked="#drawable/choice_selected"
swipe:swipeDrawableUnchecked="#drawable/choice_unselected"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeMode="left"
swipe:swipeActionLeft="reveal"
swipe:swipeOpenOnLongPress="false"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:id="#+id/pastViewLayout"
android:layout_height="match_parent">
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="#+id/linear_pastSubEmpty"
android:layout_height="wrap_content"
android:layout_below="#+id/pastBottomView">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/pastSubList"
android:divider="#ffffffff"
android:dividerHeight="1dp"
android:layout_weight="1" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:id="#+id/suspViewLayout"
android:layout_height="match_parent">
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="#+id/linear_suspendedSubEmpty"
android:layout_height="wrap_content"
android:layout_below="#+id/suspBottomView">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:id="#+id/suspSubList"
android:divider="#ffffffff"
android:dividerHeight="1dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
I got to know that there is no direct way to achieve this, I followed the following method.
public static void SetListViewHeightBasedOnChildren(ListView listView) {
IListAdapter listAdapter = listView.Adapter;
if (listAdapter == null) {
return;
}
int totalHeight = listView.PaddingTop + listView.PaddingBottom;
for (int i = 0; i < listAdapter.Count; i++) {
View listItem = listAdapter.GetView(i, null, listView);
if (listItem is ViewGroup) {
listItem.LayoutParameters = new global::Android.Views.ViewGroup.LayoutParams (global::Android.Views.ViewGroup.LayoutParams.WrapContent, global::Android.Views.ViewGroup.LayoutParams.WrapContent);
}
listItem.Measure(0, 0);
totalHeight += listItem.MeasuredHeight;
}
global::Android.Views.ViewGroup.LayoutParams parameters = listView.LayoutParameters;
parameters.Height = totalHeight + (listView.DividerHeight * (listAdapter.Count - 1));
listView.LayoutParameters = parameters;
}
Related
I have a layout where I have to add something on top and then at bottom on list view so I don't want to scroll only I want to scroll only list view I want to scroll whole screen so I added this code.
//Remove scrolling from list view so that It scroll whole screen
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ActionBar.LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
here is my 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/header"
android:orientation="horizontal"
android:layout_alignLeft="#+id/body"
android:layout_marginBottom="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="#+id/body"
android:orientation="vertical"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="#+id/header"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:paddingTop="10dp"
>
<ScrollView
android:layout_width="match_parent"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:layout_marginBottom="#dimen/activity_horizontal_margin"
android:weightSum="2"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:text="RSHO Doses"
android:layout_weight="1"
android:textColor="#636363"
android:textSize="#dimen/sub_Heading_Size"
android:drawablePadding="10dp"
android:drawableLeft="#drawable/rsho_drawable"
android:layout_height="wrap_content" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="#dimen/sub_Heading_Size"
android:text="Seizures"
android:drawablePadding="10dp"
android:drawableLeft="#drawable/seizures_drawable"
android:textColor="#636363"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:text="Events"
android:padding="#dimen/activity_horizontal_margin"
android:background="#color/colorHeadingBG"
android:textSize="#dimen/sub_Heading_Size"
android:textColor="#color/colorHeading"
android:layout_height="wrap_content" />
<ListView
android:layout_width="match_parent"
android:dividerHeight="2dp"
android:divider="#e5e5e5"
android:layout_alignParentTop="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingBottom="#dimen/activity_horizontal_margin"
android:id="#+id/listView"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
so when I open this application it remove scrolling from list view and add whole list view height in page but it always open from bottom. any solution for this
Try using this setting.
listView.setNestedScrollingEnabled(false);
listView.setHasFixedSize(false);
This way the scroll of ListView will be disabled.
I have one relativeLayout and three view's inside RelativeLayout. There views are place on each other.
<RelativeLayout
android:id="#+id/includelayoutgroup"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/transparentColorView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="visible" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keyboard_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<include
layout="#layout/transfer_keyboard_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/finalRequestView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="visible">
<include
layout="#layout/fragment_transfer_new_version_container_child"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
Is it a possible to reverse position my view's? I mean,in my code last Layout is finalRequestView and in button click i would to my last view in first position,and other view's place on my view,
How i can solve this problem?
I try to reverse layout by following demo & it works as you want, please take a look
ReverseLayout.java
public class ReverseLayout extends AppCompatActivity {
LinearLayout llRoot;
Button btReverseLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reverse_layout);
llRoot = (LinearLayout) findViewById(R.id.llRoot);
btReverseLayout = (Button) findViewById(R.id.btReverseLayout);
btReverseLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ArrayList<View> alViews = new ArrayList<View>();
for (int i = llRoot.getChildCount() - 1; i >= 0; i--) {
View view = llRoot.getChildAt(i);
llRoot.removeViewAt(i);
alViews.add(view);
}
for (int j = 0; j < alViews.size(); j++) {
llRoot.addView(alViews.get(j));
}
}
});
}
}
reverse_layout.xml layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.tosc185.testproject.Activity6">
<LinearLayout
android:id="#+id/llRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btReverseLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Reverse Layout" />
</RelativeLayout>
I'm trying to use 2 recycler views in 1 linear layout.
A recycler view will generate its own scroll but other data remains intact on the screen, so how do I combine everything into 1 scrolling area?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/grey"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:weightSum="100">
<LinearLayout
android:id="#+id/sliderhome"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="70">
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
/>
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="#+id/custom_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="30"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout 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="vlabs.chorbazaar.HomeFragment"
android:background="#color/white"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
I'm trying to make my slider and recycler view to scroll as one, but the slider is stuck at a constant place while the recycler view scrolls as usual.
change xml file:
<?xml version="1.0" encoding="utf-8"?><LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/grey"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:weightSum="100">
<LinearLayout
android:id="#+id/sliderhome"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="70">
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
/>
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="#+id/custom_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="30"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
viewpager adapter:
private class MyPagerAdapter extends FragmentPagerAdapter {
ArrayList<String> arrayList
public MyPagerAdapter(FragmentManager fm, ArrayList<String> arrayList ) {
super(fm);
this.arrayList = arrayList;
}
#Override
public Fragment getItem(int pos) {
switch(pos) {
case 0: return FirstFragment.newInstance(arraylist);
case 1: return SecondFragment.newInstance(arraylist);
}
#Override
public int getCount() {
return 2;
}
}
}
in activty:
ViewPager pager = (ViewPager) findViewById(R.id.viewPager);
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), arrayList));
fragment in xml file:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
i want to implement Globe-Weis File Folder like picture below which by clicking on green button it scrolling smoothly up and by clicking on the green button again ,the folder page scrolling down smoothly.
what i try so far was putting three scrollView in a frameLayout , and to open and close it
if (!underIsOpen) {
ObjectAnimator
.ofInt(sv_Under, "scrollY",
findViewById(R.id.ll_under_botton).getTop())
.setDuration(1000).start();
underIsOpen = true;
} else {
ObjectAnimator
.ofInt(sv_Under, "scrollY",
findViewById(R.id.ll_under_s_part).getTop())
.setDuration(1000).start();
underIsOpen = false;
}
but it just work on the scrollView which is on top
my code is:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test3);
ll_under_s_part = (LinearLayout) findViewById(R.id.ll_under_s_part);
sv_Under = (ScrollView) findViewById(R.id.scrollView1);
sv_Mid = (ScrollView) findViewById(R.id.scrollView2);
sv_Top = (ScrollView) findViewById(R.id.scrollView3);
}
public void onClick_under_left(View v) {
Toast.makeText(getApplicationContext(), "under layout",
Toast.LENGTH_SHORT).show();
if (!underIsOpen) {
ObjectAnimator
.ofInt(sv_Under, "scrollY",
findViewById(R.id.ll_under_botton).getTop())
.setDuration(1000).start();
underIsOpen = true;
} else {
ObjectAnimator
.ofInt(sv_Under, "scrollY",
findViewById(R.id.ll_under_s_part).getTop())
.setDuration(1000).start();
underIsOpen = false;
}
}
public void onClick_mid_left(View v) {
Toast.makeText(getApplicationContext(), "mid layout",
Toast.LENGTH_SHORT).show();
}
public void onClick_top_left(View v) {
Toast.makeText(getApplicationContext(), "top layout",
Toast.LENGTH_SHORT).show();
if (!topIsOpen) {
ObjectAnimator
.ofInt(sv_Top, "scrollY",
findViewById(R.id.ll_top_botton).getTop())
.setDuration(1000).start();
topIsOpen = true;
} else {
ObjectAnimator
.ofInt(sv_Top, "scrollY",
findViewById(R.id.ll_top_s_part).getTop())
.setDuration(1000).start();
topIsOpen = false;
}
}
xml:
<?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="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/ll_under_s_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#ccff00"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/ll_under_botton"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#519B57"
android:onClick="onClick_under_left"
android:orientation="vertical"
android:text="B T N" />
<LinearLayout
android:id="#+id/ll_under_p_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#edf5ee"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_under_1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_under_2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1000dp"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/ll_mid_s_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#00000000"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_mid_3"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/ll_mid_botton"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#088da5"
android:onClick="onClick_mid_left"
android:orientation="vertical"
android:text="B T N" />
<LinearLayout
android:id="#+id/ll_mid_p_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#e6f3f6"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_mid_1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:id="#+id/scrollView3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/ll_top_s_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#00000000"
android:orientation="vertical"
android:visibility="visible" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_top_3"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/ll_top_2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/ll_top_botton"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D11141"
android:onClick="onClick_top_left"
android:orientation="vertical"
android:text="B T N" />
<LinearLayout
android:id="#+id/ll_top_p_part"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#fae7ec"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>
the second way i tried was using animation but no success to result i am looking for :
public void SlideUP(View view, Context context) {
view.startAnimation(AnimationUtils.loadAnimation(context,
R.anim.slid_up));
}
public void SlideDown(View view, Context context) {
view.startAnimation(AnimationUtils.loadAnimation(context,
R.anim.slid_down));
}
any other way that i can implement this?
I don't think adding so may layout on a single screen with scrollbars is a good idea, you can apply simple frame layouts and list them accordingly and when clicking on any of the desired folder icons just animate it towards top, and it will also show the content of the folder.
https://github.com/kikoso/Swipeable-Cards
you could customize this library to do that, I have done a similar kind of app and applied the same library with my custom changes.
I have RelativeLayoutin top Scroll View, and now i want when pull down RelativeLayoutin hint and pull up RelativeLayoutin show.
How i do?
My xml
<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="fill_parent"
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" >
<RelativeLayout
android:id="#+id/Rlayout_top"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp" />
</RelativeLayout>
<ScrollView
android:id="#+id/Scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/Rlayout_top"
android:paddingBottom="20dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</RelativeLayout>
Thank you!
try this :
private float lastPosition=0;
scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
#Override
public void onScrollChanged() {
int scrollY = rootScrollView.getScrollY(); //for verticalScrollView
if(scrollY >lastPosition){
// hide your RelativeLayout
}else {
//show your view
}
lastPosition=scrollY
});