ScrollView не работает нормально, поскольку он не прокручивается плавно - PullRequest
0 голосов
/ 12 апреля 2020

Я создал простое действие, используя ScrollView> RelativeLayout> (Child: Linear Layout). Я добавил около 20 кнопок, чтобы пользовательский интерфейс можно было прокручивать (только для тестирования), но он лежит в мобильном телефоне. Прокрутка не гладкая. Вот код:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="10"
    tools:context=".MainActivity"
    android:background="@drawable/manbackground"
    >
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="5dp">
   <ImageView
    android:id="@+id/user_dp"
    android:layout_alignParentRight="true"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:src="@drawable/user"
    android:contentDescription="TODO"></ImageView>
    <ImageView
    android:id="@+id/menu_opener"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:src="@drawable/menu"
    android:layout_alignParentLeft="true"
    ></ImageView>
    <TextView
     android:id="@+id/app_name"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_toRightOf="@+id/menu_opener"
     android:text="Cool App"
     android:textSize="25dp"
     android:layout_marginLeft="10dp"
     android:textColor="#FFF"
     ></TextView>
     <ImageView
     android:id="@+id/notification_bell"
     android:layout_width="25dp"
     android:layout_height="25dp"
     android:layout_marginRight="10dp"
     android:layout_toLeftOf="@+id/user_dp"
     android:src="@drawable/bell"></ImageView>
        <TextView
                android:id="@+id/notification_num"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/notification_bell"
                android:text="10"
                android:textSize="15dp"
                android:textColor="#FFF"
                android:layout_marginLeft="-20dp"
                android:layout_marginTop="-5dp"
                ></TextView>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_marginTop="100dp"
            >

            <Button
                android:id="@+id/button17"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Button" />
<!---- I repeated this button 20 times to make the scrollview working --->
        </LinearLayout>
        </RelativeLayout>
</ScrollView>

Но когда я запустил приложение на Android Mobile, прокрутка не плавная, и она запаздывает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...