implement Globe-Weis File Folder in android - android

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.

Related

How to hide widget when keyboard pops?

I have two ViewPager on the same view with weight= 70/30 . The problem is when the keyboard pops, my both view keep the same weight and do not display my EditText.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="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:focusableInTouchMode="true"
tools:context="com.suez.memboard.fragments.formWaterQuality">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="30">
<com.suez.memboard.controls.TextView
android:id="#+id/path"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textAppearance="#style/FreeTextBold" />
<LinearLayout
android:id="#+id/date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<com.suez.memboard.controls.TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="forms.label.intervention_date"
android:textAppearance="#style/FreeText"
android:textSize="15sp" />
<com.suez.memboard.controls.TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" : "
android:textAppearance="#style/FreeText"
android:textSize="15sp" />
<com.suez.memboard.controls.DateTimeText
android:id="#+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:drawableRight="#drawable/ic_date_range_black_24dp"
android:focusable="false"
android:hint="forms.label.intervention_date"
fab:type="date" />
</LinearLayout>
<Spinner
android:id="#+id/spin_location"
android:layout_width="match_parent"
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_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="#+id/tabA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/suez_blue_1"
app:tabGravity="fill" />
<ImageButton
android:id="#+id/buttonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/suez_blue_1"
android:src="#drawable/ic_add_box_white_48dp" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewA"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="70">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="#+id/tabB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/suez_blue_1"
app:tabGravity="fill" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewB"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<FAB ....>
I think my last solution is to make disappear my picker at the top when my keyboard pops. How can I do this?
Hope this help you :
public class YourActivity extends BaseActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
attachKeyboardListeners();
}
#Override
protected void onShowKeyboard(int keyboardHeight) {
// when keyboard is shown
yourWidget.setVisibility(View.GONE);
}
#Override
protected void onHideKeyboard() {
// when keyboard is hidden
yourWidget.setVisibility(View.VISIBLE);
}
}
Try to use ScrollView in parent view, for example-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="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:focusableInTouchMode="true">
<ScrollView
android:id="#+id/scroll_view_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
..................................
type your code here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:orientation="vertical">
..................................
type your code here
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
You can set listeners when keyboard is opened and closed.
// ContentView is the root view of the layout of this activity/fragment
contentView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
Rect r = new Rect();
contentView.getWindowVisibleDisplayFrame(r);
int screenHeight = contentView.getRootView().getHeight();
// r.bottom is the position above soft keypad or device button.
// if keypad is shown, the r.bottom is smaller than that before.
int keypadHeight = screenHeight - r.bottom;
Log.d(TAG, "keypadHeight = " + keypadHeight);
if (keypadHeight > screenHeight * 0.15) { // 0.15 ratio is perhaps enough to determine keypad height.
// keyboard is opened
} else {
// keyboard is closed
}
}
});

Reverse layouts inside RelativeLayout programmatically

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>

Clicking Children Item in Sliding Panel triggers parent first?

I am using sliding panel layout and in that i have ONE floating buttons.Now when i Click on the button the view Slides first and then i have to click again on button to perform action.
I want to perform action on only single click without the sliding movement of parent view.
Look at these images
Look at 1 images
look at this
Here is my
XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:id="#+id/Sliding"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:id="#+id/leftSide"
android:background="#ef3"
>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contact"
android:background="#drawable/bg_key"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:background="#color/colorAccent"
android:id="#+id/rightSide"
android:layout_marginLeft="170dp"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="mini"
android:focusable="false"
app:srcCompat="#drawable/ic_menu_camera"
android:id="#+id/call"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/message" />
</RelativeLayout>
</android.support.v4.widget.SlidingPaneLayout>
here is my java code
SlidingPaneLayout sp;
#Override
protected void onCreate(Bundle savedInstanceState)
{
context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
call = (FloatingActionButton) findViewById(R.id.call);
sp = (SlidingPaneLayout) findViewById(R.id.Sliding);
assert sp != null;
sp.setPanelSlideListener(this);
sp.setSliderFadeColor(Color.TRANSPARENT);
sp.openPane();
mList = new ArrayList<Contacts>();
call.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Log.e("CALL","CALL");
try
{
if(number.isEmpty())
{
Toast.makeText(context,"Please select contact first",Toast.LENGTH_SHORT).show();
}
else
{
calling();
number=null;
}
}
catch (Exception e)
{
e.printStackTrace();
Toast.makeText(context,"This is not the valid contact",Toast.LENGTH_SHORT).show();
}
}
});
}
Use this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v4.widget.SlidingPaneLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:id="#+id/Sliding"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:id="#+id/leftSide"
android:background="#ef3"
>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contact"
android:background="#drawable/bg_key"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</android.support.v4.widget.SlidingPaneLayout>
<RelativeLayout
android:layout_width="match_parent"
android:background="#color/colorAccent"
android:id="#+id/rightSide"
android:layout_marginLeft="170dp"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="mini"
android:focusable="false"
app:srcCompat="#drawable/ic_menu_camera"
android:id="#+id/call"
android:layout_alignParentTop="true" />
</RelativeLayout>
</RelativeLayout>

Hide RelativeLayout when pull ScrollView

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
});

Listview inside a scrollview in xamarin

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;
}

Categories

Resources