Android在显示软键盘时调整布局的一部分

标签 android android-layout keyboard

我想创建一个布局,该布局由图像和下一个图像中显示的少量 EditTexts 组成的正常条件
Before editing

但是当用户开始输入文本时,我需要通过以下方式更改布局:
屏幕底部的软键盘,
EditTexts about it but Image is resized according to the size of soft keyboard as displayed here
After the keyboard
我该怎么做? 提前致谢

最佳答案

试试这段代码

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

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

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

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

</LinearLayout>

同时设置

android:windowSoftInputMode="adjustResize"

作为 AndroidManifest.xml 中 Activity 的属性

关于Android在显示软键盘时调整布局的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43323091/

相关文章:

android - Espresso : String in adapterView

java - Android中如何在SQLite中插入大数据

java - 如何将 C++ 集成到 Android Java 应用程序中?

android - 如何从外部库中排除 'jar' 文件

Android - 如何将 Activity 布局膨胀成 fragment ?

Android OnEditorActionListener() actionId 在我单击“完成”时给出 0

android - Syncano Android SDK - 检查用户是否登录

java - Android 通过多种布局进行导航

linux - Xorg下怎么输入greek alpha?

keyboard - 如何在 Xamarin Forms 中按下按钮时关闭键盘