0

I am a self learner of android and I am trying to make an app that displays message as Toast.I made the app on Android Studio and it seems okay but when I run it on my phone which runs on Android 5.0 ,all the widgets are overlapped while in studio all of it looks fine.Please Help. This is how it looks on phone:

This is how it looks on Andro

This is how it looks on Android

enter image description here

<?xml version="1.0" encoding="utf-8"?>

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.rahulranjan.toast1.MainToast">



<Button
    android:id="@+id/test1"
    android:layout_width="368dp"
    android:layout_height="wrap_content"
    android:onClick="btnClick"
    android:text="Click Me"
    android:textColor="#00C957"
    tools:layout_editor_absoluteY="130dp"
    tools:layout_editor_absoluteX="8dp" />

<TextView
    android:id="@+id/textView"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:text="Click Below to see Toast :"
    tools:layout_editor_absoluteY="40dp"
    tools:layout_editor_absoluteX="112dp"
    android:textColor="#E3CF57"
    />

And yeah I have used ConstrainLayout,I don't know why its not displaying here on this site. Thanks

tahsinRupam
  • 6,325
  • 1
  • 18
  • 34

1 Answers1

0

Edit:

You're using a constraint layout. You're not giving these constraints. Add constraints to these or else they default pop to the top left:

<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Click Below to see Toast :"
tools:layout_editor_absoluteY="40dp"
tools:layout_editor_absoluteX="112dp"
android:textColor="#E3CF57"
app:layout_constraintLeft_toRightOf="@id/test1"
/>
Matthew Bahr
  • 337
  • 1
  • 15