0

I'm trying to add a few icons for a custom bottom navigation bar in my layout, and when I tried to add them, the NestedScrollView that occupies most of the screen has become very slow, the scrolling doesn't go smoothly with the touch gestures anymore just because of adding a few icons. I don't understand this behavior of the NestedScrollViews. It contains a recyclerview by the way. I've put up my layout code here. The bottom_layout, which contains a view group with four icon-sized images causes the issue. If I have 1 or 2 images instead, there is no issue at all.

Edit: If possible, I would like to have some advice on a good way to load a layout which has lists as children of a scrolling view.

XML:

<RelativeLayout 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="#ffffff"
tools:context=".activities.PlacesActivity">


<LinearLayout
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:layout_marginTop="22sp"
    android:background="#555555"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/place_toolbar_title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="10dp"
        android:layout_weight="0.2"
        android:gravity="center_vertical"
        android:textColor="#f4e92c"
        android:textSize="21sp" />

    <!-- android:text="Cubbon Park" for the above textview-->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="0.9"
        android:gravity="center">

        <ImageView
            android:id="@+id/places_profile_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_marginLeft="12dp"
            android:layout_marginTop="4sp"
            android:padding="5dp"

            android:src="@drawable/profile3x" />
    </LinearLayout>
</LinearLayout>

<android.support.v4.widget.NestedScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/bottom_layout"
    android:layout_below="@id/toolbar"
    android:fillViewport="true"
    app:layout_anchor="@id/toolbar"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical">


        <ImageView
            android:id="@+id/image_place_header"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="centerCrop"

            />


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="5dp"
            android:background="#ececef" />


        <android.support.v7.widget.CardView 

xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:id="@+id/map_card_place"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center">

            <LinearLayout
                android:id="@+id/map_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">


                    <ImageView
                        android:id="@+id/map_icon"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:src="@drawable/location3x" />

                    <TextView
                        android:id="@+id/labelOnMap"
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:layout_gravity="center_vertical"
                        android:gravity="center_vertical"
                        android:paddingLeft="5dp"
                        android:text="Point of Interest"
                        android:textColor="#757575"
                        android:textSize="20sp" />


                </LinearLayout>


                <fragment xmlns:android="http://schemas.android.com

/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:id="@+id/map"


android:name="com.testapp.android.WorkaroundMapFragment"
                    android:layout_width="match_parent"
                    android:layout_height="170dp"


tools:context="com.example.googlemap.MapsActivity" />
            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!--recyclerview containing all the content-->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/metadata"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    </LinearLayout>

</android.support.v4.widget.NestedScrollView>


<include
    android:id="@+id/bottom_layout"
    layout="@layout/bottom_bar"
    android:layout_width="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_height="40dp" />

<ImageButton
    android:id="@+id/fab_main"
    android:layout_width="62dp"
    android:layout_height="62dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:background="?attr/selectableItemBackgroundBorderless"
    android:scaleType="fitCenter"
    android:src="@drawable/btn_scan_large" />



</RelativeLayout>
Tanveer Munir
  • 1,936
  • 1
  • 10
  • 25
Harsha Vardhan
  • 336
  • 3
  • 12

1 Answers1

0

I found out the solution to remove sluggishness was to just place the images in drawable-nodpi folder.

found this answer here helpful:

https://stackoverflow.com/a/51960548/10165076

Harsha Vardhan
  • 336
  • 3
  • 12