changed layout for every device

This commit is contained in:
oxidiert
2025-09-06 20:18:26 +02:00
parent 90e662a330
commit 6aebda0009
18 changed files with 855 additions and 446 deletions

View File

@ -2,6 +2,8 @@ package com.dano.test1
import android.view.View
import android.widget.*
import android.util.TypedValue
import androidx.core.widget.TextViewCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -28,12 +30,21 @@ class HandlerClientCoachCode(
val clientCodeField = layout.findViewById<EditText>(R.id.client_code)
val coachCodeField = layout.findViewById<EditText>(R.id.coach_code)
val questionTextView = layout.findViewById<TextView>(R.id.question)
val titleTextView = layout.findViewById<TextView>(R.id.textView)
// Fill question text using language manager
questionTextView.text = question.question?.let {
LanguageManager.getText(languageID, it)
} ?: ""
// --- Schriftgrößen prozentual zur Bildschirmhöhe setzen ---
// Passe die Prozente bei Bedarf an:
setTextSizePercentOfScreenHeight(titleTextView, 0.03f) // 5.5% der Bildschirmhöhe
setTextSizePercentOfScreenHeight(questionTextView,0.03f) // 5.0% der Bildschirmhöhe
setTextSizePercentOfScreenHeight(clientCodeField, 0.025f) // 3.5% der Bildschirmhöhe
setTextSizePercentOfScreenHeight(coachCodeField, 0.025f) // anpassen nach Geschmack
// ----------------------------------------------------------
// Load last used client code if available
val lastClientCode = GlobalValues.LAST_CLIENT_CODE
if (!lastClientCode.isNullOrBlank()) {
@ -58,6 +69,14 @@ class HandlerClientCoachCode(
}
}
// Deaktiviert AutoSize und setzt textSize in sp prozentual zur Bildschirmhöhe
private fun setTextSizePercentOfScreenHeight(view: TextView, percentOfHeight: Float) {
val dm = layout.resources.displayMetrics
val sp = (dm.heightPixels * percentOfHeight) / dm.scaledDensity
TextViewCompat.setAutoSizeTextTypeWithDefaults(view, TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE)
view.setTextSize(TypedValue.COMPLEX_UNIT_SP, sp)
}
// Handle Next button click
private fun onNextClicked(clientCodeField: EditText, coachCodeField: EditText) {
if (!validate()) {
@ -99,7 +118,6 @@ class HandlerClientCoachCode(
}
}
// Handle Previous button click
private fun onPreviousClicked(clientCodeField: EditText, coachCodeField: EditText) {
val clientCode = clientCodeField.text.toString()