android:windowSoftInputMode =“ adjustResize”不适用于TranslucentTheme活动

时间:2019-12-23 13:21:18

标签: android android-layout

出于某些原因,以下代码不适用于 TranslucentTheme 活动。如果该活动已知问题或其他需要注意的地方,请提供帮助。

注意:根据我的观察,如果我删除了半透明主题,则此代码可以正常工作。

<activity
    android:windowSoftInputMode="stateHidden|adjustResize"
    android:name="MyActivity"
    android:theme="@style/TranslucentTheme"/>

 <style name="TranslucentTheme" parent="NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>

activity_layout.xml
<ScrollView
    android:layout_alignParentTop="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">
    <androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_gravity="bottom"
        android:background="@color/transparent"
        android:layout_width="match_parent"
        android:layout_height="100dp"

         <EditText
            android:digits="1234567890"
            android:inputType="number"
            android:background="#00000000"
            android:id="@+id/day_box"
            android:minWidth="@dimen/dimen_12dp"
            tools:text="123"
            android:fontFamily="sans-serif-medium"
            android:textColor="#000000"
            android:textStyle="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>```

1 个答案:

答案 0 :(得分:0)

使用Theme.AppCompat.Light.NoActionBar代替NoActionBar

<style name="TranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>