use*_*240 26 android android-layout android-fragments
我目前正在构建一个Android应用程序,使用户可以拍照并写下它的细节.该应用程序使用Sherlock库.
我已经实现了一个SherlockFragment来显示图像和一些EditText和TextView,使用户能够键入图像的信息.但是,当其中一个EditText处于焦点上时,所有字段都会向上推,软键盘会弹出.
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="200dip"
android:layout_above="@+id/textView"
android:layout_marginTop="20dip"
android:layout_marginBottom="20dip"
android:contentDescription="desc" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title:"
android:textStyle="bold"
android:layout_above="@+id/editTextSimple"
android:layout_marginBottom="2dip"
android:textSize="15sp"/>
<EditText
android:id="@+id/editTextSimple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_marginBottom="4dip">
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description:"
android:textStyle="bold"
android:layout_above="@+id/editTextSimple1"
android:layout_marginBottom="2dip"
android:textSize="15sp"/>
<EditText
android:id="@+id/editTextSimple1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_marginBottom="12dip">
</EditText>
<Button android:textColor="#FF000000"
android:id="@+id/submitButton"
android:text="@string/memorySubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dip"
android:onClick = "submit"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
根据我的理解,在一个活动中,必须将其置于<activity android:windowSoftInputMode="...." >Android Manifest中以在调用软键盘时调整视图.但是,我们如何为片段设置它?
ken*_*ggy 58
在我使用多个布局和viewstub来创建消息传递屏幕的场景中,这对我有用.把它放在onCreate()希望这会有所帮助.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)
Evo*_*vos 11
一个片段的所有片段与Activity其父片段具有相同的行为Activity,但如果您需要不同的键盘行为Fragments,则可以从Fragment代码中动态更改此属性,如下所示:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.softInputMode.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
小智 8
这可以在Fragment Class中用于向上移动Edit文本并向下滚动直到结束.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Run Code Online (Sandbox Code Playgroud)
小智 8
android:windowSoftInputMode="adjustPan"
Run Code Online (Sandbox Code Playgroud)
与该活动相关的所有片段的行为都相同,如果您想更改特定片段的行为而不是使用以下片段
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33062 次 |
| 最近记录: |