我正在为谷歌电视创建一个叠加层。我创建了一个透明主题,以便通过应用程序可以看到广播,如下所示:
样式.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="Invisible" parent="@android:style/Theme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
不使用此主题时,我可以使用以下方式显示带有图片的自定义吐司:
View layout = inflater.inflate(R.layout.toast,
(ViewGroup) findViewById(R.id.custom_toast_layout_id));
// Toast...
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
但是,当我使用此主题时,它不会显示,只会显示标准吐司:
Toast.makeText(this, "This game is over. Start a new game.", Toast.LENGTH_SHORT).show();
吐司只是在屏幕中间显示一张图片,所以不需要很复杂。
非常感谢任何帮助。