My custom Android toast shows no text



wise people!


This is my first question here. I'm stuck with a problem that seemed pretty simple to solve to me. I am not able to show a custom Toast message in my Android app.


There are two custom layouts I've created



  1. my_toast.xml - layout file





<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/toast_layout_root"
android:layout_width="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="wrap_content">

<TextView
android:id = "@+id/text"
android:background="@color/yumist_red"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="#fff"
android:text = "ToastText"
android:gravity = "center"
/>

</LinearLayout>




  1. my_toast_up.xml





<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/toast_layout_root"
android:layout_width="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="wrap_content">


<ImageView
android:layout_width="30dp"
android:layout_height="10dp"
android:src="@drawable/chat_arrow"
android:rotation="180"
/>

<TextView
android:id = "@+id/text"
android:background="@color/yumist_red"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="#fff"
android:text = "ToastText"
android:gravity = "center"
/>

</LinearLayout>



The only difference in the two is an imageview containing an arrow image. I'm trying to create text-bubble-style Toast.


I am well able to show and use the first one in my app. But, when I use the second layout with the image, all I see is the Image and an empty TextView of the ImageView's width and standard height. I've tried a lot of posts and existing questions online, but I cannot find a solution to this.


Any help?


No comments:

Post a Comment