如果线性布局的重力=“底部”时滚动不起作用,该怎么办?

问题描述 投票:0回答:1

我通过将消息元素动态添加到linearlayout来显示聊天。我遇到了一个问题。在输入时,抬起键盘滚动条不应低于该水平,并且键盘不应关闭该消息,这是合乎逻辑的。为此,我使用了linearlayout属性gravity = bottom,但是现在滚动不起作用。请告诉我们如何使滚动条不是从上到下,而是从下到上]

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

       android:gravity="bottom|center_horizontal"
       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:layout_gravity="bottom"
           android:baselineAligned="false"
           android:adjustViewBounds="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">


       </LinearLayout>
   </ScrollView>      


android android-studio scrollview android-linearlayout
1个回答
0
投票

这是对我有用的怪异解决方法。尝试将android:elevation =“ 4dp”添加到线性布局。这不是您应该使用android重力的方式。

© www.soinside.com 2019 - 2024. All rights reserved.