fixed rotate screen bug

This commit is contained in:
oxidiert
2025-09-06 20:34:01 +02:00
parent 6aebda0009
commit 45deee664b
3 changed files with 16 additions and 7 deletions

View File

@ -31,7 +31,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="locked">
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View File

@ -1,5 +1,6 @@
package com.dano.test1
import android.content.res.Configuration
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
@ -12,11 +13,20 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize the opening screen handler and show the opening screen
// Opening Screen nur beim echten Start initialisieren.
// Durch configChanges wird onCreate bei Drehung NICHT erneut aufgerufen.
openingScreenHandler = HandlerOpeningScreen(this)
openingScreenHandler.init()
}
// Wichtig: Bei Konfigurationsänderungen NICHT den Screen neu setzen.
// So bleibt man auf der aktuellen Frage/Seite.
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
// Kein setContentView(), kein openingScreenHandler.init() hier!
// Falls du Layout-Metriken bei Rotation neu berechnen willst, kannst du das gezielt hier tun.
}
/**
* Starts the given questionnaire and attaches it to this activity.
* @param questionnaire The questionnaire instance to start.
@ -44,7 +54,6 @@ class MainActivity : AppCompatActivity() {
* Finish the questionnaire and return to the opening screen.
*/
fun finishQuestionnaire() {
// For example, switch back to the opening screen:
isInQuestionnaire = false
isFirstQuestionnairePage = false
openingScreenHandler.init()

View File

@ -68,12 +68,12 @@
android:id="@+id/date_spinner_year"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:tag="year"
android:gravity="start|center_vertical"
android:textAlignment="viewStart"
android:paddingStart="8dp"
android:tag="year"
android:textAlignment="viewStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.932"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/question"
app:layout_constraintWidth_percent="0.32" />
@ -106,7 +106,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.932"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/date_spinner_year"
app:layout_constraintWidth_percent="0.32" />