fixed rotate screen bug
This commit is contained in:
@ -31,7 +31,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:screenOrientation="locked">
|
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.dano.test1
|
package com.dano.test1
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
@ -12,11 +13,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
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 = HandlerOpeningScreen(this)
|
||||||
openingScreenHandler.init()
|
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.
|
* Starts the given questionnaire and attaches it to this activity.
|
||||||
* @param questionnaire The questionnaire instance to start.
|
* @param questionnaire The questionnaire instance to start.
|
||||||
@ -44,7 +54,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
* Finish the questionnaire and return to the opening screen.
|
* Finish the questionnaire and return to the opening screen.
|
||||||
*/
|
*/
|
||||||
fun finishQuestionnaire() {
|
fun finishQuestionnaire() {
|
||||||
// For example, switch back to the opening screen:
|
|
||||||
isInQuestionnaire = false
|
isInQuestionnaire = false
|
||||||
isFirstQuestionnairePage = false
|
isFirstQuestionnairePage = false
|
||||||
openingScreenHandler.init()
|
openingScreenHandler.init()
|
||||||
|
|||||||
@ -68,12 +68,12 @@
|
|||||||
android:id="@+id/date_spinner_year"
|
android:id="@+id/date_spinner_year"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:tag="year"
|
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
|
android:tag="year"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.932"
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/question"
|
app:layout_constraintTop_toBottomOf="@id/question"
|
||||||
app:layout_constraintWidth_percent="0.32" />
|
app:layout_constraintWidth_percent="0.32" />
|
||||||
@ -106,7 +106,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.932"
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/date_spinner_year"
|
app:layout_constraintTop_toBottomOf="@id/date_spinner_year"
|
||||||
app:layout_constraintWidth_percent="0.32" />
|
app:layout_constraintWidth_percent="0.32" />
|
||||||
|
|||||||
Reference in New Issue
Block a user