相关疑难解决方法(0)

Android当软键盘可见时,如何在全屏模式下调整布局

当软键盘处于活动状态并且我已成功实现它时,我已经研究了很多调整布局但是当我android:theme="@android:style/Theme.NoTitleBar.Fullscreen"在清单文件中的活动标签中使用它时问题就出现了.

为此,我使用android:windowSoftInputMode="adjustPan|adjustResize|stateHidden"了不同的选项,但没有运气.

之后,我以FullScreen编程方式实现并尝试了各种布局,FullScreen但都是徒劳的.

我引用了这些链接,并在此处查看了许多与此问题相关的帖子:

http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html

http://davidwparker.com/2011/08/30/android-how-to-float-a-row-above-keyboard/

这是xml代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/masterContainerView"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#ffffff">

    <ScrollView android:id="@+id/parentScrollView"
        android:layout_width="fill_parent" android:layout_height="wrap_content">

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

            <TextView android:id="@+id/setup_txt" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Setup - Step 1 of 3"
                android:textColor="@color/top_header_txt_color" android:textSize="20dp"
                android:padding="8dp" android:gravity="center_horizontal" />

            <TextView android:id="@+id/txt_header" android:layout_width="fill_parent"
                android:layout_height="40dp" android:text="AutoReply:"
                android:textColor="@color/top_header_txt_color" android:textSize="14dp"
                android:textStyle="bold" android:padding="10dp"
                android:layout_below="@+id/setup_txt" />

            <EditText android:id="@+id/edit_message"
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:text="Some text here." android:textSize="16dp"
                android:textColor="@color/setting_editmsg_color" android:padding="10dp"
                android:minLines="5" android:maxLines="6" android:layout_below="@+id/txt_header"
                android:gravity="top" android:scrollbars="vertical"
                android:maxLength="132" />

            <ImageView android:id="@+id/image_bottom"
                android:layout_width="fill_parent" android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-layout android-softkeyboard

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

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万
查看次数

弹出软键盘时页面滚动

我有一个<ScrollView>布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_scrollview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >

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

        <EditText
            android:id="@+id/input_one"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

         <EditText
            android:id="@+id/input_two"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

         <EditText
            android:id="@+id/input_three"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

          <Button
            android:id="@+id/ok_btn"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:text="@string/ok_str" />

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

如上所示,简单布局包含三个输入字段和一个"确定"按钮.

我使用上面的布局运行我的应用程序,当我点击第一个输入字段(@+id/input_one)时,软键盘将从屏幕底部弹出,它隐藏第三个输入字段和"确定"按钮.

自从我使用以来<ScrollView>,我想我可以向上滚动页面以查看第三个输入字段和软键盘隐藏的"确定"按钮,但页面不可滚动.为什么?如何摆脱它?基本上,我想看到每个输入字段和"确定"按钮,甚至软键盘弹出.

android android-keypad android-intent android-layout android-scrollview

88
推荐指数
7
解决办法
11万
查看次数

软键盘打开时调整布局

我在一些应用程序中看到,当显示软键盘时,布局会发生变化.这当然不是adjustPan因为整个布局(可能是内部布局)的变化,而不仅仅是当前的变化EditText.例如,这是在Evernote登录屏幕中.你能告诉我这是怎么做的吗?

android

37
推荐指数
3
解决办法
6万
查看次数

android软键盘出现时会破坏布局

这是一个布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1" />

        <FrameLayout
            android:background="#0000ff"
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1" />

    </LinearLayout>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

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

在此输入图像描述

当触摸EditText并出现软键盘时,我希望蓝条保持不变.即我希望保留它的大小和位置.我android:windowSoftInputMode在AndroidManifest中尝试了我的activity参数的所有四个可能值.并且总是我的蓝色条在软键盘上移动或缩小:

android:windowSoftInputMode="adjustUnspecified" 或默认情况下:

在此输入图像描述

android:windowSoftInputMode="adjustPan"或者android:windowSoftInputMode="adjustNothing":

在此输入图像描述

android:windowSoftInputMode="adjustResize":

在此输入图像描述

当软键盘出现时,它是否可以保持相同的大小和位置?

android android-layout android-softkeyboard

10
推荐指数
2
解决办法
5694
查看次数

键盘出现时,android调整大小布局

我想在键盘出现时重新定位布局,例如在编辑文本字段时,以便在聚焦字段上获得可见性.我试过windowSoftInputMode,但我没有任何区别.怎么到达?谢谢.

<activity 
            android:name="com.xxxx.projecte1.TabBar_Activity"      
            android:theme="@android:style/Theme.NoTitleBar"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize"
           />
Run Code Online (Sandbox Code Playgroud)

java android

8
推荐指数
3
解决办法
1万
查看次数

如何在显示软键盘时保持所有字段和文本可见

我正在这个登录屏幕上工作,我希望在显示 IME 时调整所有字段、文本和按钮的大小。我已经在 androidManifest.xml 上使用了 android:windowSoftInputMode="adjustResize",但我仍然在其他元素下面得到一些元素。

如果 TextView“Cadastre Agora”(id= 地籍)仍然被虚拟键盘覆盖,这并不重要。但是,我希望至少 EditTexts、它们的 TextViews 和按钮是可见的。

我发现这个悬而未决的问题可能是一个有趣的方法:http://stackoverflow.com/questions/6484024/soft-keyboard-keep-one-view-stationary-while-moving-other

感谢您的帮助!

没有输入法的屏幕:http : //imageshack.us/photo/my-images/138/semttulo2mr.png/

带有 IME 的屏幕(TextView1 变为隐藏):http : //imageshack.us/photo/my-images/404/semttulo3xw.png/

Stackoverflow 抱怨我的代码格式,所以我在这里上传了 xml 文件:https://rapidshare.com/files/1767398103/login.xml 而且我不能发布超过 2 个链接,这就是我在其中添加空格的原因。

xml keyboard layout android

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

Android片段底部奇怪的空白区域?

我遇到了一个奇怪的问题:片段底部有一个空白区域,我无法摆脱它.值得一提的是,如果我点击任何按钮,这个空间就会消失.

任何帮助表示赞赏!请在下面找到屏幕截图和布局代码.

截图

DetailActivity布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.ogasimli.manat.activity.DetailActivity"
tools:ignore="MergeRootFrame" />
Run Code Online (Sandbox Code Playgroud)

DetailFragment布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.ogasimli.manat.fragment.DetailActivityFragment"
android:background="@color/colorAccent">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/detail_result_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:visibility="gone"
    tools:visibility="visible">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        app:elevation="0dp"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_detail"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.AppBarOverlay"/>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_marginTop="?actionBarSize"
        android:weightSum="7">

        <include layout="@layout/detail_chart_grid"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4.5"/>

        <include layout="@layout/detail_extras_grid"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2.5"/>

    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_share_details"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="24dp"
        android:elevation="8dp"
        android:src="@drawable/ic_share"
        app:layout_anchor="@id/cardview_details"
        app:layout_anchorGravity="top|right|end"
        app:rippleColor="@color/colorPrimary"
        tools:targetApi="lollipop"/>

</android.support.design.widget.CoordinatorLayout>

<LinearLayout
    android:id="@+id/detail_error_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

xml layout android fragment android-fragments

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

出现软键盘时,布局不会向上推

我已经设计好了 这个通过采取从参考布局这个和编码相同如下.

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/action_bar_color"
        android:minHeight="?attr/actionBarSize">

        <TextView
            android:id="@+id/txt_user_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="@dimen/image_margin_left"
            android:text="@string/app_name"
            android:textColor="@android:color/black"
            android:textSize="@dimen/login_txt_size" />

        <ImageView
            android:id="@+id/img_refresh"
            android:layout_width="@dimen/logo_image_w"
            android:layout_height="@dimen/logo_image_h"
            android:layout_gravity="right"
            android:layout_marginLeft="@dimen/image_margin_left"
            android:background="@drawable/custom_image_click"
            android:src="@drawable/ic_action_refresh" />

        <ImageView
            android:id="@+id/img_setting"
            android:layout_width="@dimen/logo_image_w"
            android:layout_height="@dimen/logo_image_h"
            android:layout_gravity="right"
            android:layout_marginLeft="@dimen/image_margin_left"
            android:background="@drawable/custom_image_click"
            android:src="@drawable/ic_action_settings" />

        <ImageView
            android:id="@+id/img_wifi"
            android:layout_width="@dimen/logo_image_w"
            android:layout_height="@dimen/logo_image_h"
            android:layout_gravity="right"
            android:layout_marginLeft="@dimen/image_margin_left"
            android:background="@drawable/custom_image_click"
            android:src="@drawable/ic_wifi_on"
            android:tint="@color/button_theme_color" />

    </android.support.v7.widget.Toolbar>
    <TextView
        android:id="@+id/tv_home_networkStatus"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#003b60"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Medium Text"
        android:textColor="#FFFF0000"
        android:textSize="20sp"
        android:visibility="visible" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:fillViewport="true"
        android:gravity="center">

        <LinearLayout
            android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-softkeyboard

3
推荐指数
1
解决办法
548
查看次数