【问题标题】:View at the bottom of RelativeLayout does not stick to the keyboardRelativeLayout 底部的视图不粘在键盘上
【发布时间】:2018-04-05 15:05:37
【问题描述】:
<RelativeLayout>

    <AppBarLayout>

        ...

    </AppBarLayout>

    <LinearLayout
        android:id="@+id/tool_list"
        android:layout_width="match_parent"
        android:layout_height="@dimen/editor_item_size"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal">

        ...

    </LinearLayout>

    <ScrollView
        android:id="@+id/custom_setting_panel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/tool_list"
        android:layout_below="@id/appBarLayout">

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

            <LinearLayout
                android:id="@+id/category_area"
                android:layout_width="match_parent"
                android:layout_height="56dp">

                ...

            </LinearLayout>

            <LinearLayout
                android:id="@+id/title_area"
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:layout_below="@id/category_area"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="@dimen/editor_item_size"
                    android:layout_height="match_parent"/>

                <EditText
                    android:id="@+id/title_edit"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"/>

            </LinearLayout>

            <View
                android:id="@+id/divider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@+id/title_area"
                android:background="@color/colorDivider" />

            <jp.wasabeef.richeditor.RichEditor
                android:id="@+id/editor"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:layout_below="@id/divider"/>

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>

这是我的 writeActivity.xml

当我像这样点击title_edit时。

我想要下图这样的流程。

但它并没有按照我想要的方式工作。

它是这样工作的。

我认为我以前可以这样做,但我认为我错了。

我添加了一个滚动视图,但它似乎没有任何区别。

我该怎么做图2?

【问题讨论】:

标签: android android-softkeyboard android-scrollview android-relativelayout


【解决方案1】:

在该活动的应用清单文件中使用android:windowSoftInputMode="adjustResize" 并将android:fitsSystemWindows="true" 添加到根RelativeLayout。希望能做到这一点

【讨论】:

  • 臭小子,应该这样做:/ 你能显示你的清单文件吗?
  • @monoz 当然,等一下
  • 从这里添加了一条注释stackoverflow.com/a/21860837/6407116,以便在您的根相对布局中使用 fitSystemWindows。也可以暂时不使用adjustPan
  • 一定和富编辑器有关。我建议在 xml 中将其注释掉并使用 tool_list 测试键盘是否正常工作,然后将其放回原处。抱歉:(
  • 感谢您的帮助。我会考虑将richeditor 更改为edittext。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-30
相关资源
最近更新 更多