Scrolling problems when using ScrollView
denisxor opened this issue Β· comments
Hi!
Thanks for great library and for your work!
I try to use FoldingCells as a static (defined in XML) menu organizer.
Basically I have the following layout structure:
<FoldingCell 1>
<FoldingCell 2>
<FoldingCell 3>
When I unfold Cell 1 its title and several upper unfolded elements goes beyond top border of the screen and can't be seen or scrolled to be seen. If I unfold second and third Cells things get worse - unfolded Cell1 practically disappears beyond top of the screen.
Here are screenshoots (second screenshot - only Cell 1 (top one) is unfolded).
I don't want to use ListView because components of my menu are not generic list items (each Cell has different number of contained TextViews (buttons)). What can I do to get all unfolded cells visible and scrollable?
XML layout is:
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/id_main_menu_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/mm_background"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:gravity="bottom"
>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/id_lathe_menu_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_normal"
>
<!-- UNFOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Lathe turning"
android:background="@color/colorBlackOverlay"
style="@style/MainMenuCategory" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="9dp">
<TextView
android:id="@+id/id_lathe_cutting_speed_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Cutting speed"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_lathe_feed_rate_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Feed rate"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_lathe_off_center_turning_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Off center turning"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_lathe_cutters_angles_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Cutters angles"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_lathe_change_gears_calc_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Change gears calculation"
style="@style/MainMenuBtn" />
</LinearLayout>
</LinearLayout> β
<!-- FOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorBlackOverlay"
android:baselineAligned="false"
android:orientation="horizontal">
<!-- LEFT TITLE PART -->
<RelativeLayout
android:layout_width="175dp"
android:layout_height="175dp"
android:background="#00000000"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
>
<ImageView
android:id="@+id/id_menu_item_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/mm_lathe_icon"
/>
</RelativeLayout>
<!-- RIGHT TITLE PART -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorOverlay"
android:paddingBottom="20dp"
android:paddingEnd="20dp"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:paddingStart="15dp"
android:paddingTop="20dp">
<TextView
android:id="@+id/id_folded_category_name"
style="@style/MainMenuCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
android:text="Lathe turning" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> β
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/id_mill_menu_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_normal"
>
β
<!-- UNFOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<TextView
android:id="@+id/id_unfolded_category_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Milling"
android:background="@color/colorBlackOverlay"
style="@style/MainMenuCategory" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="9dp">
<TextView
android:id="@+id/id_mill_cutting_speed_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Cutting speed"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_hex_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_hex_square_diameters"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_mill_feed_rate_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Mill feed rate"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_flange_calc_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Flange holes calculation"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_gear_module_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Gear size calculation"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_dividing_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="Dividing"
style="@style/MainMenuBtn" />
</LinearLayout>
</LinearLayout> β
<!-- FOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorBlackOverlay"
android:baselineAligned="false"
android:orientation="horizontal">
<!-- LEFT TITLE PART -->
<RelativeLayout
android:layout_width="175dp"
android:layout_height="175dp"
android:background="#00000000"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/mm_mill_icon"
/>
</RelativeLayout>
<!-- RIGHT TITLE PART -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorOverlay"
android:paddingBottom="20dp"
android:paddingEnd="20dp"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:paddingStart="15dp"
android:paddingTop="20dp">
<TextView
style="@style/MainMenuCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
android:text="Milling" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> β
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/id_toolbox_menu_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_normal"
>
β
<!-- UNFOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Misc. tools"
android:background="@color/colorBlackOverlay"
style="@style/MainMenuCategory" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="9dp">
<TextView
android:id="@+id/id_tools_threads_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_threads_act_caption"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_tools_fits_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_fits"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_tools_cones_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_cones"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_tools_expansion_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_thermal_expansion"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_tools_visual_thermometer_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_heat_treatment"
style="@style/MainMenuBtn" />
<TextView
android:id="@+id/id_tools_level_resolution_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginBottom="@dimen/spacing_normal"
android:text="@string/str_action_level"
style="@style/MainMenuBtn" />
</LinearLayout>
</LinearLayout> β
<!-- FOLDED lathe group layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorBlackOverlay"
android:baselineAligned="false"
android:orientation="horizontal">
<!-- LEFT TITLE PART -->
<RelativeLayout
android:layout_width="175dp"
android:layout_height="175dp"
android:background="#00000000"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/mm_file_icon"
/>
</RelativeLayout>
<!-- RIGHT TITLE PART -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorOverlay"
android:paddingBottom="20dp"
android:paddingEnd="20dp"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:paddingStart="15dp"
android:paddingTop="20dp">
<TextView
style="@style/MainMenuCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
android:text="Misc tools" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> β
</com.ramotion.foldingcell.FoldingCell>
</LinearLayout>
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Hello, @denisxor. This layout works perfectly:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:orientation="vertical">
<Button
android:id="@+id/toggle_instant_btn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Toggle instantly" />
<Button
android:id="@+id/toggle_btn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Toggle with animation" />
</LinearLayout>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@android:color/holo_green_dark"
android:gravity="center"
android:text="Content view" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_dark"
android:gravity="center"
android:text="Title view" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@android:color/holo_green_dark"
android:gravity="center"
android:text="Content view" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_dark"
android:gravity="center"
android:text="Title view" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@android:color/holo_green_dark"
android:gravity="center"
android:text="Content view" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_dark"
android:gravity="center"
android:text="Title view" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@android:color/holo_green_dark"
android:gravity="center"
android:text="Content view" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_dark"
android:gravity="center"
android:text="Title view" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@android:color/holo_green_dark"
android:gravity="center"
android:text="Content view" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_dark"
android:gravity="center"
android:text="Title view" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
</LinearLayout>
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I don't think your issue related to folding cell. There probably an issue in your layout.xml.