Search code examples
androidtextview

Text is showing in one phone but not on another phone when running app fron android studio


I have one phone which is Samsung M51 and another is a lava iris model. When I run the app in lava, it runs normally but doesn't show text view, on another hand when it runs on Samsung, it runs without any problem. Why these two different results having the same code.Code in my app


Solution

  • You're using hardcoded margins which are almost 700dp, Lava Iris's screen size is too small for these margins. You should use a proper layout (e.g. ConstraintLayout) to place the TextView on the screen.

        <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <TextView
            android:id="@+id/tv_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Example"
            app:layout_constraintEnd_toStartOf="@+id/textView"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Example"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/tv_1"
            app:layout_constraintTop_toTopOf="parent" />
    
    </androidx.constraintlayout.widget.ConstraintLayout>