debugging - Row of TextViews not displaying on Samsung Galaxy 33 device - Stack Overflow

I have been working on an app for a while, which is in production on the store. At the last revision a

I have been working on an app for a while, which is in production on the store. At the last revision a problem appeared when running the app on a Samsung Galaxy 33A device. The problem does not show up on emulator nor on other Android devices.

Description of the issue

In a constraint layout, there is a horizontal linear layout with seven textViews containing numbers:

3, 4, ...9

in standard sans-serif font. Beside there is an imageView extending over the range of the linear layout and also one textView containing the letter M. The linear layout has an elevation of 5dp to stay visible in front of the image view.

The purpose of the view is to let the user select a range of numbers by adjusting the length of the image view with the finger. Here is what it looks like on emulators and for example on a Xiaomi HyperOS for example:

And here is what it looks like on the Samsung Galaxy 33A. The numbers do not show up:

Does anyone know of such a bug specific to Samsung devices ? What would be the recommandation to solve such an issue ? Thanks for any advice.

XML xode of the layout:

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/plageEtCartouche"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="16dp">

    <LinearLayout
        android:id="@+id/plageNombreLettres"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:elevation="5dp"
        android:gravity="start"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="3"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="4"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="5"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="6"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="7"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="8"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="9"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

    </LinearLayout>

    <ImageView
        android:id="@+id/cartouche"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginEnd="160dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/cartouche" />

    <TextView
        android:id="@+id/btnMono"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="1"
        android:fontFamily="cursive"
        android:gravity="center"
        android:includeFontPadding="false"
        android:text="M"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/plageNombreLettres"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Fragment

And by the way, in the Fragment there is a few lines of code to adjust the size of the textViews and imageView to fit he size of the screen:

private fun initConstraints() {
    pasNombre = (largeurEcran - 56.dp) / 10
    for (view in binding.plageNombreLettres) {
        view.updateLayoutParams<LinearLayout.LayoutParams> {
            width = pasNombre
        }
    }
    binding.plageEtCartouche.updateLayoutParams<LinearLayout.LayoutParams> {
        height = pasNombre
    }
    val startCons = filtre.lMin.start
    val endCons = filtre.lMax.end
    binding.cartouche.updateLayoutParams<ConstraintLayout.LayoutParams> {
        marginStart = startCons
        marginEnd = endCons
    }
} 

I have been working on an app for a while, which is in production on the store. At the last revision a problem appeared when running the app on a Samsung Galaxy 33A device. The problem does not show up on emulator nor on other Android devices.

Description of the issue

In a constraint layout, there is a horizontal linear layout with seven textViews containing numbers:

3, 4, ...9

in standard sans-serif font. Beside there is an imageView extending over the range of the linear layout and also one textView containing the letter M. The linear layout has an elevation of 5dp to stay visible in front of the image view.

The purpose of the view is to let the user select a range of numbers by adjusting the length of the image view with the finger. Here is what it looks like on emulators and for example on a Xiaomi HyperOS for example:

And here is what it looks like on the Samsung Galaxy 33A. The numbers do not show up:

Does anyone know of such a bug specific to Samsung devices ? What would be the recommandation to solve such an issue ? Thanks for any advice.

XML xode of the layout:

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/plageEtCartouche"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="16dp">

    <LinearLayout
        android:id="@+id/plageNombreLettres"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:elevation="5dp"
        android:gravity="start"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="3"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="4"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="5"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="6"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="7"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="8"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="9"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

    </LinearLayout>

    <ImageView
        android:id="@+id/cartouche"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginEnd="160dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/cartouche" />

    <TextView
        android:id="@+id/btnMono"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="1"
        android:fontFamily="cursive"
        android:gravity="center"
        android:includeFontPadding="false"
        android:text="M"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/plageNombreLettres"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Fragment

And by the way, in the Fragment there is a few lines of code to adjust the size of the textViews and imageView to fit he size of the screen:

private fun initConstraints() {
    pasNombre = (largeurEcran - 56.dp) / 10
    for (view in binding.plageNombreLettres) {
        view.updateLayoutParams<LinearLayout.LayoutParams> {
            width = pasNombre
        }
    }
    binding.plageEtCartouche.updateLayoutParams<LinearLayout.LayoutParams> {
        height = pasNombre
    }
    val startCons = filtre.lMin.start
    val endCons = filtre.lMax.end
    binding.cartouche.updateLayoutParams<ConstraintLayout.LayoutParams> {
        marginStart = startCons
        marginEnd = endCons
    }
} 
Share Improve this question edited Jan 31 at 8:41 Simon W asked Jan 31 at 8:35 Simon WSimon W 698 bronze badges 1
  • Tested on Redmi 6 Pro : no issue. – Simon W Commented Jan 31 at 12:53
Add a comment  | 

1 Answer 1

Reset to default 0

I managed to solve the problem by kind of coming back to the previous version that had worked before : I put the M textView into the linearLayout with one empty textView on each side (to center it in the remain space without expanding it).

I also had to update the loop for sizing the numbers in the Fragment.

And now it works on Samsung Galaxy as well. Don't ask me why !

I must say I also upgraded a few dependencies in the build.gradle.kts that were not up-to-date, like:

implementation("androidx.constraintlayout:constraintlayout:2.2.0")

Corrected XML

   <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/plageEtCartouche"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="16dp">

    <LinearLayout
        android:id="@+id/plageNombreLettres"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:elevation="5dp"
        android:gravity="start"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="3"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="4"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="5"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="6"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="7"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="8"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="9"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/empty1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/btnMono"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="1"
            android:fontFamily="cursive"
            android:gravity="center"
            android:includeFontPadding="false"
            android:text="M"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/empty2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="1"
            android:gravity="center"
            android:includeFontPadding="false"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold" />

    </LinearLayout>

    <ImageView
        android:id="@+id/cartouche"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginEnd="160dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/cartouche" />

</androidx.constraintlayout.widget.ConstraintLayout>

Updated loop in the Fragment

private fun initConstraints() {
    pasNombre = (largeurEcran - 56.dp) / 10
    for (index in 0..<(binding.plageNombreLettres.childCount - 3)) {
        val view = binding.plageNombreLettres.getChildAt(index)
        view.updateLayoutParams<LinearLayout.LayoutParams> {
            width = pasNombre
        }
    }
    binding.plageEtCartouche.updateLayoutParams<LinearLayout.LayoutParams> {
        height = pasNombre
    }
    val startCons = filtre.lMin.start
    val endCons = filtre.lMax.end
    binding.cartouche.updateLayoutParams<ConstraintLayout.LayoutParams> {
        marginStart = startCons
        marginEnd = endCons
    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745274703a4619966.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信