相关疑难解决方法(0)

android中adjustResize和adjustPan的区别?

我尝试编写一个代码,用于在出现软键盘时重新调整UI组件的大小.当我使用adjustResize时,它重新调整UI组件的大小,同时adjustPan给了我相同的输出.我想知道它们之间的区别以及何时使用每个组件?哪一个(adjustPan或adjustResize)有助于调整UI的大小?

这是我的xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

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

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/editText5"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="45dp"
                android:ems="10"
                android:inputType="textPersonName" />

            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="40dp"
                android:text="My Button" />
        </LinearLayout>
    </RelativeLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

和清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.adjustscroll"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.adjustscroll.MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustPan|adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard

115
推荐指数
6
解决办法
13万
查看次数

使用adjustPan时软键盘隐藏ActionBar

我需要设置所有这三个项目可见
1. ActionBar
2. ListView
3. EditText(在底部)
当我点击时EditText,它推动背景图像并挤压它.我看到一些教程和使用android:windowSoftInputMode="adjustPan",解决了挤压问题,但创建了一个新的.当它SoftKeyboard出现时,它也隐藏了ActionBar.我访问过很多问题,但其中没有一个问题确实有用.有没有办法设置ActionBar 始终可见屏幕上发生的任何事情......

EDITED

xml片段的用于显示ListViewEditText是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


    <ListView
        android:id="@id/android:list"
        style="@style/ContactListView"
        android:layout_width="match_parent"
        android:layout_height="389dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:isScrollContainer="false" />

    <TextView
        android:id="@id/android:empty"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_above="@+id/editText1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:fontFamily="sans-serif-light"
        android:gravity="center"
        android:text="@string/no_contacts"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:background="@android:color/holo_blue_dark"
        android:ems="10" 
        android:imeOptions="flagNoExtractUi"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

编辑(第二)

快照是:

在此输入图像描述 在此输入图像描述

android android-layout android-listview android-actionbar

6
推荐指数
1
解决办法
4692
查看次数

键盘出现时ActionBar隐藏

我正在使用ActionBarSherlock.windowSoftInputModeadjustPan(我已尝试过adjustResize,adjustNothing也).

我想ActionBar在键盘出现时保持在屏幕上但是滑动我的布局(因此文本仍然可见).

这是它看起来正确的方式: 在此输入图像描述

键盘出现时: 在此输入图像描述

问题是:如何ActionBar在使用时保持可见adjustPan(因此EditTexts始终可见)?

注意 我不能ScrollView用来握住我的View

android actionbarsherlock

5
推荐指数
1
解决办法
4736
查看次数