我有一个典型的listview有edittext,并在活动底部的按钮.
当我点击它时edittext,软键盘出现,我可以滚动它中的项目,listview但它重新调整我的背景图像的大小.
我试过android:windowSoftInputMode="adjustResize"但没有区别.
我试过了android:windowSoftInputMode="adjustPan".图像不会被压扁,整个布局向上移动,我失去了标题栏.如果列表项超出布局大小,我只能滚动列表.
基本上,我想维护标题栏,保留背景图像而不重新调整大小并允许滚动列表项.有人设法做到了吗?谢谢!
Bol*_*rme 42
对于listview你需要使用
android:isScrollContainer="false"
Run Code Online (Sandbox Code Playgroud)
并将其添加到manifest.xml中的活动中
android:windowSoftInputMode="adjustPan"
Run Code Online (Sandbox Code Playgroud)
Gem*_*Gem 23
我试过这样可以解决这个问题的解决方案.android:windowSoftInputMode ="adjustPan"将使你的整个屏幕转换键盘.通常我们在屏幕顶部有一个标题.使用此标志它也会离开可见区域,这会带来糟糕的用户体验.我使用android:windowSoftInputMode="adjustResize"这将调整整个屏幕的大小,但它会在问题中导致同样的问题@Maurice状态.
所以这是我的最终解决方案:
在清单中
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
Run Code Online (Sandbox Code Playgroud)
在XMl中
不要在这里设置任何背景.并在ScrollView下保持您的视图
在Java中
您需要将背景设置为窗口:
getWindow().setBackgroundDrawableResource(R.drawable.bg_wood) ;
Run Code Online (Sandbox Code Playgroud)
小智 9
转到Androidmanifest.xml并:
activity name="activityname" android:windowSoftInputMode="stateVisible|adjustPan"
Run Code Online (Sandbox Code Playgroud)
小智 5
无法阻止软键盘调整背景图像的大小。
使用它scaleType(matrix)并准备合适的图像。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/RelativeLayoutchat"
>
<LinearLayout
android:orientation="horizontal"
android:gravity ="clip_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true">
<ImageView
android:gravity ="clip_horizontal"
android:id="@+id/chat_bak_img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix">
</ImageView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/chat"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:transcriptMode="alwaysScroll"
android:divider="#000000"
android:clickable="false"
android:layout_weight="9"
android:cacheColorHint="#00000000"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
style="@android:style/ButtonBar"
android:gravity="center"
android:paddingLeft="3dip"
android:paddingTop="3dip"
android:paddingRight="3dip">
<EditText
android:id="@+id/chatMsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="5"
android:enabled="true"
android:textSize="17sp"
android:maxLength="150"/>
<Button
android:id="@+id/sendMsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/send_withSpace"
android:layout_weight="4"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36523 次 |
| 最近记录: |