2013-03-23 29 views
1

进出口创造了谷歌电视的应用程序。我正尝试在广播顶部创建一个自定义的烤面包覆盖层。如何实现土司覆盖在谷歌电视

我已经创建的自定义敬酒如下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/custom_toast_layout_id" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#FFF" 
android:orientation="horizontal" 
android:padding="5dp" > 

<TextView 
    android:id="@+id/text" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:textColor="#000" /> 

</LinearLayout> 

,并在GoogleTV的应用程序的视图来实现它:

 LayoutInflater inflater = getLayoutInflater(); 

      View layout = inflater.inflate(R.layout.main, 
      (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(); 

我的问题是如何使这个应用程序显示正常在应用程序中广播信息,以便在观看期间触发此覆盖图?

任何帮助非常感谢。

回答

2

这里有这样一些方法:

  1. 您可以创建一个应用程序,用户必须明确地推出每一次,他们希望看到这样的面包在他们的直播之前。该应用程序将具有透明的活动,然后显示敬酒或仅显示信息的视图。您的活动将阻止所有其他与广播的互动,例如更换频道。

  2. 调用从服务的烤面包或透明活性。看看这个开放源代码的应用程序:https://github.com/entertailion/Overlay-for-GTV

  3. 您也可以使用Android支持的系统警报窗口来覆盖任何其他活动之上的视图,而不是使用Toast或透明视图。你需要在你的清单“android.permission.SYSTEM_ALERT_WINDOW”,你需要设置窗口类型为“WindowManager.LayoutParams.TYPE_SYSTEM_ALERT”。

+0

嗨感谢您的回答。我已经创建了应用程序,但我应该如何设置顶级线性布局的透明度?我试过android:background =“@ android:color/transparent”但仍显示黑色? “:windowIsTranslucent机器人”谢谢 – EHarpham 2013-03-23 16:17:33

+0

与创建一个透明的风格。看看覆盖应用链接的确切样式。 – 2013-03-23 18:27:24