0
我已经为我的吐司消息创建了自定义视图。自定义吐司定位
我希望我的吐司消息占用屏幕的宽度,比如左右两边有30dp的余量。
但它最终会填满整个屏幕,如果Toast消息的文本/内容很长(并且包装很多,如果内容较少)。我希望它在宽度上保持相同的大小(即整个屏幕宽度减去左边和右边的边距),并根据其中的内容来包装高度(增加/减少)。
这是我目前吐司XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_root"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/jtoast_bg"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp">
<ImageView
android:id="@+id/toast_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:scaleType="fitStart"
android:src="@drawable/menu_info">
</ImageView>
<TextView
android:id="@+id/toast_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:textSize="14sp"
android:gravity="center"
android:text="toast text"
android:textColor="#FFF">
</TextView>
,它被填充为:
View layout = inflater.inflate(R.layout.jtoast,(ViewGroup)activity.findViewById(R.id.toast_root));
..
toast.setGravity(Gravity.BOTTOM, 40, 40);
..
林我的敬酒不尊重底部填充我消息太长。有没有找到解决方案? – richari1987 2015-01-08 19:42:56