Android 活动进行得如何;“调整大小”;属性实际上是有效的

Android 活动进行得如何;“调整大小”;属性实际上是有效的,android,android-edittext,android-softkeyboard,android-input-method,Android,Android Edittext,Android Softkeyboard,Android Input Method,这些天我在学习软键流行音乐的时候,知道了活动布局是如何改变的。然后我写了一个样本,发现了一些奇怪的东西 以下是我的布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout

这些天我在学习软键流行音乐的时候,知道了活动布局是如何改变的。然后我写了一个样本,发现了一些奇怪的东西

以下是我的布局:

<LinearLayout     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"
    android:orientation="vertical"
    tools:context="com.margi.inputbar.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="1" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="2" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="3" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="4" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="5" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="6" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="7" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="8" />



    </LinearLayout>


<include layout="@layout/layout_input" />

这是舱单:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

XML布局是:

线性布局有八个子文本视图

然后软键盘弹出:

xml布局为:

LinearLayout只有4个子文本视图

下面是我想找到答案的两个问题:

(1) 我想知道当显示软键盘时,到底发生了什么,消失的文本视图在哪里


(2) 是否有任何文档、文件或博客对此进行解释?我已经阅读了谷歌的文档,但对此我仍然不是很清楚。

您的“活动”保持不变,但很可能是inputmethodeditor(IME)更改了当前显示的视图,添加了类似“滚动视图”的系统,允许部分呈现屏幕(因为没有计算将被重写的屏幕部分的值)。这是“操作系统更改”,因此,作为开发人员,您无法在应用程序上更改此行为,但O.S.可以更改您的应用程序。每个IME的行为可能不同,并且至少有一个IME服务始终处于活动状态。它的行为方式取决于此。我猜具有“WindowsOFInputMode”属性的活动会做一些技巧,但我在活动源代码中找不到相关代码。所以,我想知道,我猜是对的吗?如果是对的,活动中的相关代码在哪里?如果不是,当软键盘弹出时,系统如何知道活动中的哪个视图应该调整布局,以及调整布局的策略是什么t当软键盘弹出时。您可以在android.inputmethodservice软件包中找到源代码。
…关注以下功能:
updateInputViewShowed()
setInputView(视图视图)
onCreateInputView()
onCreateExtractTextView()
…这些可能是最常见的,基本上,
InputMethodService
必须知道在某些特定场景中它将如何呈现,并且操作系统将为开发人员调用这些回调。请注意,这通常意味着大约50%的屏幕使用率(以及当前视图作为数据的滚动视图),或者在某些情况下,一个唯一提取的视图和几乎所有其他使用的内容。thks非常常用,我将尝试阅读源代码以找出原因。