Art*_*ius 2 android padding android-layout kotlin android-actionbar
我在我的应用程序上添加了新的 Splashscreen API (androidx.core:core-splashscreen:1.0.0-rc01),之后我的边距/填充被破坏,但仅适用于我的启动器活动 (MainActivity),特别是从此活动打开的对话框片段。在其他活动中,没问题,一切正常。
下面是我的对话框片段,没有实现启动画面,我的填充/边距都正常:

现在有了 Splashscreen 实现:
[
我按照开发人员 Android 文档的说明进行操作:https ://developer.android.com/reference/kotlin/androidx/core/splashscreen/SplashScreen
在我的 MainActivy.kt 中
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
Run Code Online (Sandbox Code Playgroud)
在 Manifest.xml 中,我在 MainActity 中添加了以下代码
android:theme="@style/AppTheme.AppStarting"
Run Code Online (Sandbox Code Playgroud)
在我的 Splashscreen 主题中,我已将“postSplashScreenTheme”设置为我的原始主题
<style name="AppTheme.AppStarting" parent="Theme.SplashScreen">
<item name="postSplashScreenTheme">@style/AppTheme</item>
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_foreground</item>
</style>
Run Code Online (Sandbox Code Playgroud)
最后,我的对话框片段是在我的应用程序中随处使用的相同 XML,并在relativelayout 中进行填充:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
Run Code Online (Sandbox Code Playgroud)
此问题仅适用于 MainActivity 中的 DialogFragment 或 AlertDialog,其他组件或其他活动中的 DialogFragment 没有问题...有什么想法吗?
小智 5
我有同样的问题。甚至在 EditTextfields 内的所有填充都消失了。就我而言,它是在 postSplashScreenTheme 中将 FitsSystemWindows 设置为 true。
环境
fitsSystemWindows = false
Run Code Online (Sandbox Code Playgroud)
为我解决了问题。