【问题标题】:How do I make a scrollview grow and scroll up?如何使滚动视图增长并向上滚动?
【发布时间】:2020-04-22 21:47:13
【问题描述】:

我的问题是我向LinearLayout添加了新消息,而ScrollView每次都有“离开”的属性。或者,例如,打开的键盘会导致滚动条下沉。我尝试使用 layout_gravity 底部,这给了我想要的结果,但滚动不起作用。本质上我的问题是如何从 layout_gravity 底部允许向上滚动。这是我的 xml:

<ScrollView
android:id="@+id/messscroll"
android:layout_width="match_parent"
android:layout_height="0dp"

app:layout_constraintBottom_toTopOf="@+id/relativeLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">

<LinearLayout
    android:id="@+id/messagebox"

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"

    android:baselineAligned="false"
    android:clickable="true"
    android:divider="@drawable/separator"
    android:dividerPadding="3dp"

    android:focusable="false"
    android:focusableInTouchMode="false"
    android:orientation="vertical"
    android:paddingBottom="1px"
    android:showDividers="middle"/>

【问题讨论】:

    标签: android xml scrollview android-linearlayout gravity


    【解决方案1】:

    对于干扰 ScrollView 的键盘相关问题,您可以在 Activity 的 Manifest 条目中使用android:windowSoftInputMode="stateAlwaysHidden|adjustPan",例如

    <activity
        android:name=".activities.LoginActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
    

    【讨论】:

    • 我的意思是它的作品,但我打字的时候有一个空的地方
    • 在您的帖子中添加更多描述以及可能的屏幕截图可能会帮助其他人帮助您!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    • 2020-12-21
    • 2020-10-05
    • 2020-01-09
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    相关资源
    最近更新 更多