2016-07-05 34 views
0

我遇到了顯示佈局問題。 當您放置可見時,Relativelayout @ + id/media不可見。他仍然在Relativelayout @ + id/media2下,可以從dpad中選擇,但仍然在其他下。未選擇Android電視按鈕

如果零件放了media2第一和第二個媒體。媒體可見時,但不能選擇dpad。

有一定的順序使媒體儘管首先被寫在media2之上嗎? 謝謝

佈局

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    android:id="@+id/app_video_box" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="#000" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:id="@+id/media" 
     android:layout_marginLeft="32dp" 
     android:layout_marginRight="32dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" 
      android:gravity="center_vertical|center_horizontal|center" 
      android:layout_marginLeft="32dp" 
      android:layout_marginRight="32dp" 
      android:animateLayoutChanges="true" 
      android:background="#e72a2a" 
      android:id="@+id/relativeLayout"> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Back" 
       android:id="@+id/button2" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/button" 
       android:layout_toEndOf="@+id/button" /> 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Play" 
       android:id="@+id/button" /> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Next" 
       android:id="@+id/button3" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/button2" 
       android:layout_toEndOf="@+id/button2" /> 

     </RelativeLayout> 

     <SeekBar 
      android:id="@+id/app_video_seekBar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:focusable="true" 
      android:layout_above="@+id/relativeLayout" 
      android:layout_alignLeft="@+id/relativeLayout" 
      android:layout_alignStart="@+id/relativeLayout" 
      android:layout_alignRight="@+id/relativeLayout" 
      android:layout_alignEnd="@+id/relativeLayout" /> 


    </RelativeLayout> 
    <RelativeLayout 
     android:id="@+id/media2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <tcking.github.com.giraffeplayer.IjkVideoView 
      android:id="@+id/video_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
    </RelativeLayout> 

</RelativeLayout> 
+0

您需要爲媒體和媒體2指定相對位置,就像您爲其他控件所做的一樣。 – muratgu

+0

你能給我更多的細節嗎? –

回答

0

好像你正在試圖控制爲重點,在屏幕上不同的項目。您可以使用XML標籤專門爲這樣的:

android:nextFocusForward="@+id/media2"

android:nextFocusDown="@+id/media2"

你可以看看docs for keyboard navigation瞭解更多信息。

0

在Android TV中,只有UI元素只有在可以聚焦時纔會被選中。 通過xml屬性或代碼實現此目的。

view.setFocusable(true) 

android:focusable="true". 

,併爲向誰要傳送的每個焦點UI元素的規則。

android:nextFocus{direction}="view_id". 

哪裏方向可能是下,頂部,右或左

可對焦項目