laobie / StatusBarUtil

A util for setting status bar style on Android App.
http://t.cn/Rq746Kb
Apache License 2.0
8.82k stars 1.72k forks source link

设置StatusBarUtil之后,影响软键盘的弹出 #43

Open YuYongzhi opened 7 years ago

YuYongzhi commented 7 years ago

activity的页面使用Rele布局,然后在底部放置EditText,点击输入框,软键盘弹出,但是输入框没有跟随向上滑

laobie commented 7 years ago

输入框这个应该需要你设置下相关的属性吧,这个和设置状态栏应该没关系的,不知道你现在解决了没

ailiboy520 commented 7 years ago

今天我也遇到这个问题 在清单文件设置 android:windowSoftInputMode="adjustResize|stateHidden" 后点击输入框,没有跟随,去掉这个状态栏后显示就可以的 具体布局是这样的

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/login_root" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/tool_bar" android:visibility="gone" /> <RelativeLayout android:id="@+id/login_bg_root" android:layout_alignParentTop="true" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/login_center" android:layout_marginBottom="20dp"

    <ImageView
        android:id="@+id/login_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@mipmap/bg_login"
        />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical"
        >
        <ImageView
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:scaleType="fitXY"
            android:src="@mipmap/image_water_mark"
            />
    </LinearLayout>

</RelativeLayout>

<TextView
    android:id="@+id/login_center"
    android:layout_width="match_parent"
    android:layout_height="1px"
    android:layout_centerInParent="true"
    />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/login_center"
    android:scrollbars="none"
    >
    <LinearLayout
        android:id="@+id/login_edit_contanter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginBottom="@dimen/edit_bottom_margin"
        android:paddingLeft="@dimen/common_left_padding"
        android:paddingRight="@dimen/common_right_padding"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/common_left_margin"
            android:layout_marginRight="@dimen/common_right_margin"
            android:orientation="horizontal"
            >
            <TextView
                android:layout_width="85dp"
                android:layout_height="@dimen/input_box_height"
                android:paddingLeft="@dimen/edit_left_padding"
                android:text="@string/account"
                android:gravity="center|left"
                style="@style/input_login_box_style"
                />
            <EditText
                android:id="@+id/et_account"
                android:layout_width="match_parent"
                android:layout_height="@dimen/input_box_height"
                android:background="@color/transparent"
                android:layout_marginLeft="20dp"
                android:digits="@string/user_name_valid_char"
                android:singleLine="true"
                style="@style/input_login_box_style" />

        </LinearLayout>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:background="@color/login_text_cseparate_color"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/common_left_margin"
            android:layout_marginRight="@dimen/common_right_margin"
            android:orientation="horizontal"
            >
            <TextView
                android:layout_width="85dp"
                android:layout_height="@dimen/input_box_height"
                android:paddingLeft="@dimen/edit_left_padding"
                android:text="@string/password"
                android:gravity="center|left"
                style="@style/input_login_box_style"
                />
            <EditText
                android:id="@+id/et_password"
                android:layout_width="match_parent"
                android:layout_height="@dimen/input_box_height"
                android:background="@color/transparent"
                android:layout_marginLeft="20dp"
                android:singleLine="true"
                android:inputType="textPassword"
                style="@style/input_login_box_style"
                />

        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:background="@color/login_text_cseparate_color"
            />

        <Button
            android:id="@+id/btn_login"
            android:layout_width="match_parent"
            android:layout_height="@dimen/common_btn_height"
            android:layout_marginTop="@dimen/btn_top_margin"
            android:layout_marginLeft="@dimen/common_left_margin"
            android:layout_marginRight="@dimen/common_right_margin"
            android:text="@string/login"
            android:textColor="@color/login_btn_text_color"
            android:background="@drawable/selector_button"
            style="@style/unify_button_style" />

        <TextView
            android:id="@+id/tv_login_forget"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp"
            android:textColor="@color/login_text_forget_color"
            android:textSize="@dimen/common_text_size"
            android:text="@string/forget"
            android:layout_gravity="center_horizontal"
            />
    </LinearLayout>
</ScrollView>

tanweijiu commented 7 years ago

这个跟透明状态栏有关,你的设备是5.0以后的版本么?

beanu commented 7 years ago

有同样的问题,使用 StatusBarUtil.setTransparentForImageView(this, rlHeader);之后 软键盘不弹出,去掉之后 就可以了。5.0以上系统

beanu commented 7 years ago

状态栏透明会影响软键盘的弹出,应该是系统的问题,不是StatusBarUtil的问题。临时解决方案是用了 StatusBarUtil.setColor

ShaunWilson commented 7 years ago

我也遇到了同样的问题,给键盘的enter键设置成搜索失效了

LingChenJie commented 7 years ago

我也遇到了,在小米手机上,如果设置状态栏透明度,就会出现软键盘把EditText给遮住。

laobie commented 7 years ago

😔

wangshaolei commented 7 years ago

@laobie 这个问题最佳兼容实践有人实验过没有

tanweijiu commented 7 years ago

问题是出在,addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS),这个flag,是会影响键盘的,键盘弹出布局自动适配这个效果是会受到多种因素影响的,比如全屏或者....(建议看看相关的资料)

wangshaolei commented 7 years ago

@tanweijiu thanks~ 有解决方案分享一下,一起看一下。

tanweijiu commented 7 years ago

@wangshaolei http://stackoverflow.com/questions/21092888/windowsoftinputmode-adjustresize-not-working-with-translucent-action-navbar/22266717#22266717 可以看看这个

wangshaolei commented 7 years ago

@tanweijiu 这里面两个方法试过了,没起作用。还有我是配合https://blog.dreamtobe.cn/2015/09/01/keyboard-panel-switch/ 这个使用StatusBarUtil的

laobie commented 7 years ago

@wangshaolei 透明会影响?setColor 会出现问题不

wangshaolei commented 7 years ago

@laobie setColor不会出现问题。是FLAG_TRANSLUCENT_STATUS这个影响的,我也是昨天晚上发现的。

wangshaolei commented 7 years ago

@Override public final WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom())); } else { return insets; } } 重写这个adJustResize 虽然有变化了,但是键盘的显示事件监听不到了。很纠结。@tanweiju

tanweijiu commented 7 years ago

@wangshaolei https://code.google.com/p/android/issues/detail?id=5497 然后你可以搜索一个工具类(AndroidBugSolutionAboutInputMethod.java)...

wangshaolei commented 7 years ago

@tanweijiu 没有搜到呢,有没有地址?thanks

wangshaolei commented 7 years ago

@tanweijiu 有没有很好解决方法呢,请教一下,你说的这个地址 貌似没有找到相关信息,谢谢~

shlockfan commented 7 years ago

如果是透明状态栏,把布局改成relativeLayout,然后想要顶起的布局放到bottom,就能顶起来了,你们可以试下,我以前遇到过。

ruanbaojun1105 commented 7 years ago

同遇到 所以就没用透明了 好坑

laobie commented 7 years ago

image