【发布时间】:2016-03-03 06:29:38
【问题描述】:
我正在尝试通过将 webview 嵌入到 android 的相对布局的滚动视图中来创建富文本编辑器。 webview 显示一个带有可编辑 div 的 html 文件。
<html>
<body>
<div id="editor" contentEditable="true"></div>
</body>
</html>
布局文件:-
<ScrollView
android:id="@+id/blog_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="30dp"
android:clipToPadding="false"
android:layout_above="@+id/Footer"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
>
<RelativeLayout
android:id="@+id/rlContent"
android:layout_width="match_parent"
android:layout_height="200px">
<com.medicodesk.ionapp.utils.editor.RichEditor
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:id="@+id/Footer"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:visibility="invisible">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:layout_above="@+id/blog_content"
android:id="@+id/blog_editor_toolbar"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageButton
android:id="@+id/action_undo"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@null"
android:contentDescription="@null"
android:src="@drawable/undo"
/>
<ImageButton
android:id="@+id/action_blockquote"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@null"
android:contentDescription="@null"
android:src="@drawable/blockquote"
/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
RichEditor 布局是 weblayout 子布局,通过调用 javascript 与 html 交互。
问题是我无法将编辑器窗口高度设置为适合 android 移动布局大小。编辑器将处于显示模式,显示用户输入的所有内容,或者将处于键盘布局从底部弹出的编辑模式。编辑器应该只能垂直滚动。我不清楚我是否应该依靠 html 滚动或 android 滚动视图来获得平滑滚动。
请帮帮我。
【问题讨论】:
标签: android webview scrollview rich-text-editor