简体   繁体   English

除非触摸屏幕,否则我的应用不会跳到起始目的地

[英]My app does not skip to the starting destination unless touch the screen

I designed an Android app with Jetpack Compose.我用 Jetpack Compose 设计了一个 Android 应用程序。 I did not change anything in themes.xml , though my app does not skip to the starting destination of my app.我没有更改themes.xml中的任何内容,尽管我的应用程序没有跳到我的应用程序的起始目的地。 A screen appears and does not go away unless i touched screen.除非我触摸屏幕,否则屏幕会出现并且不会消失。 When i change the parent line in themes.xml , android:Theme.Material.NoActionBar to android:Theme.Material.NoActionBar.FullScreen then app works fine but I don't want to make it fullscreen.当我更改 theme.xml 中的父行时, android:Theme.Material.NoActionBar themes.xml android:Theme.Material.NoActionBar.FullScreen然后应用程序工作正常,但我不想让它全屏显示。 Is it possible that is a bug ?这可能是一个错误吗?

<style

        name="Theme.TradeJournal" parent="android:Theme.Material.NoActionBar"> //👈 this line 

        <item name="android:statusBarColor">@color/purple_200</item>

    </style>

themes.xml :主题.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style

        name="Theme.TradeJournal" parent="android:Theme.Material.NoActionBar">

        <item name="android:statusBarColor">@color/purple_200</item>

    </style>

   
</resources>


AndroidManifests :安卓清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.sevban.tradejournal">

    <uses-permission android:name="android.permission.INTERNET"> </uses-permission>
    <application
        android:name=".TradeJournalApplication"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.TradeJournal"
        tools:targetApi="31">
        <activity
            android:name=".view.MainActivity"
            android:exported="true"
            android:theme="@style/Theme.TradeJournal">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Thanks in advance.提前致谢。

Maybe you should define a parent theme and create NoActionBar as it child as shown below:也许您应该定义一个父主题并创建 NoActionBar 作为它的子主题,如下所示:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryVariant">@color/colorPrimary</item>
    <item name="colorOnPrimary">@color/white</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <!-- Secondary brand color. -->
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:statusBarColor">@color/white</item>
    <item name="android:fontFamily">@font/calibri_regular</item>
    <item name="android:windowBackground">@color/white</item>
</style>

<style name="Theme.AppSplash" parent="Theme.SplashScreen">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="windowSplashScreenBackground">@color/white</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/app_logo</item>
    <item name="windowSplashScreenAnimationDuration">300</item>
    <item name="postSplashScreenTheme">@style/AppTheme.NoActionBar</item>
</style>

And in Manifest:在清单中:

<application
    android:name="****"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme.NoActionBar">

    <activity
        android:name=".ui.main.MainActivity"
        android:exported="true"
        android:theme="@style/Theme.AppSplash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Main Activity:主要活动:

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val splashScreen = installSplashScreen()
    splashScreen.setKeepOnScreenCondition { true }
    setContent {
        Content()
    }
}

} }

It was a general issue that is debating in issuetracker.这是 issuetracker 中争论的一个普遍问题。

https://issuetracker.google.com/issues/227926002 https://issuetracker.google.com/issues/227926002

Especially Xiaomi devices undergo this problem.尤其是小米设备遇到了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM