gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 15:50:23 25 4
gpt4 key购买 nike

我设计了this布局引用 this下面是相同的代码。

    <?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"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="@drawable/logo_login" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_masjid_corner"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/masjid" />

<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/user_sep" />

<EditText
android:id="@+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/round_kiosk_corner"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:padding="20dp"
android:src="@drawable/tablet" />

<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/pass_sep" />

<EditText
android:id="@+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"

android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />

<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"

android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

</LinearLayout>

</LinearLayout>
</ScrollView>



</LinearLayout>

list 代码如下

 <activity android:name=".activity.LoginActivity"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape"

android:windowSoftInputMode="adjustPan|adjustResize">
</activity>

但它仍然会给出类似 this 的输出.当软键盘出现时,按钮隐藏在软键盘下方。我尝试使用 adjustResize 以及 adjustPan,但输出仍然没有变化。我添加了 ScrollView 也是 如果有人有解决方案请帮忙

最佳答案

尝试将 ScrollView 作为父根布局,如下代码所示

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

<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" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="@drawable/logo_login" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_masjid_corner"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/masjid" />

<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/user_sep" />

<EditText
android:id="@+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/round_kiosk_corner"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:padding="20dp"
android:src="@drawable/tablet" />

<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/pass_sep" />

<EditText
android:id="@+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"

android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />

<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"

android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>

</LinearLayout>

</LinearLayout>


</LinearLayout>

</ScrollView>

比将 list 文件中的 android:windowSoftInputMode="adjustResize" 应用到您的 Activity

注意:- fullscreen mode doesn't resize

关于android - 出现软键盘时布局不会向上推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47586564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com