Sri*_*m R 3 android android-softkeyboard android-edittext android-fragments
我有一个布局,它有两个编辑文本和一个片段中带有一些图标的水平滚动条。
水平滚动视图使用相对布局约束永久固定在父级的底部。
When an edit is clicked, the soft keyboard appears by default. When that happens, I need the horizontal scroll view to float above the soft keyboard so that everyone can use it.
I have added the following line to the AndroidManifest.xml file to the activity containing the fragment
android:windowSoftInputMode="adjustResize"
Run Code Online (Sandbox Code Playgroud)
The view still doesn't work as expected.
How do I fix this?
Current Screen :
Current Screen without keyboard [Current Screen w/o keyboard]1
Current Screen with keyboard [Current Screen with keyboard]2
Expected Screens
Expected Screen without keyboard [Expected Screen w/o keyboard]3
Expected screen with keyboard [Exoected Screen with keyboard]4
And here is the fragment xml file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.github.mthli.knife.KnifeText
android:id="@+id/edt_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_notes_add"
android:background="@android:color/transparent"
android:hint="Content"
android:padding="12dp"
android:textSize="20sp"
app:historyEnable="true"
app:historySize="20" />
<EditText
android:id="@+id/title_notes_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hint="Title"
android:minLines="1"
android:padding="12dp"
android:textSize="24sp"
android:textStyle="bold" />
<HorizontalScrollView
android:id="@+id/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/undo"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_undo" />
<ImageButton
android:id="@+id/redo"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_redo" />
<ImageButton
android:id="@+id/bold"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_bold" />
<ImageButton
android:id="@+id/italic"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_italic" />
<ImageButton
android:id="@+id/underline"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_underlined" />
<ImageButton
android:id="@+id/strikethrough"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_strikethrough" />
<ImageButton
android:id="@+id/bullet"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_list_bulleted" />
<ImageButton
android:id="@+id/quote"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_quote" />
<ImageButton
android:id="@+id/link"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_insert_link" />
<ImageButton
android:id="@+id/clear"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:contentDescription="@null"
android:scaleType="center"
android:src="@drawable/ic_format_clear" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我哪里出错了,我该如何解决?
在每个 onCreateView 的片段调用中试试这个
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2918 次 |
最近记录: |