I've looked through a heap of previous answers on this , and tried the code marked as working, but so far nothing I do can convince the TextView I'm creating at runtme from filling the screen completely from left to right. I want to add a margin on both sides similar to a regular Toast. After that I can add a drop shadow to the shape.
Here my form layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rel_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical|center_horizontal"
android:text="@string/hello_world"
android:textColor="@color/holobrightblue"
android:textSize="48sp"
android:textStyle="bold"
tools:context=".MainActivity" />
</RelativeLayout>
.. and my code
textView = new TextView(m_Context);
RoundRectShape rs = new RoundRectShape(new float[] { 10, 10, 10, 10, 10, 10, 10, 10 }, null, null);
ShapeDrawable sd = new ShapeDrawable(rs);
sd.setAlpha(m_opacity);
textView.setBackgroundDrawable(sd);
textView.setTextColor(m_txtcolor);
textView.setText(toasttitle+"\n"+toastmessage);
textView.setBackgroundColor(Color.BLACK);
textView.setPadding(10,10,10,10);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
lp.setMargins(60, 0, 60, 0);
textView.setLayoutParams(lp);
toastView = new Toast(m_Context);
toastView.setView(textView);
toastView.setDuration(m_toastlen);
toastView.setGravity(m_screengravity, 0,0);
toastView.show();
As mentioned, nothing I've tried from other solutions seems to convince the textview from filling all the horizonal space.
I've tried removing that shape etc...
Any ideas?