2014-12-03 679 views
0

基本上我有2个线性布局。用户单击按钮时,一个线性布局将展开或折叠。另一个将始终显示在顶部。这里是我的xml:Android XML设置z-Index

<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

<Button 
      android:id="@+id/btnNewsFeed" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/lightred" 
      android:minHeight="20dp" 
      android:text="News feed" 
      android:textColor="#FFFFFF" /> 
<LinearLayout 
      android:id="@+id/llNewsFeed" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@+id/btnNewsFeed" 
      android:background="#FFFFFF" 
      android:orientation="vertical" 
      android:visibility="gone" > 

      <ListView 
       android:id="@+id/EventNewsFeedListview" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:listSelector="#F6CECE" > 
      </ListView> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/legendDiv" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_below="@+id/btnNewsFeed" 
      android:alpha=".75" 
      android:background="#fff" 
      android:orientation="vertical" 
      android:visibility="gone" > 

      <TableLayout 
       android:id="@+id/tableEvent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:stretchColumns="1" 
       android:visibility="gone" > 
       //Table Rows 
      </TableLayout> 
     </LinearLayout> 


</RelativeLayout> 

所以将在抽屉式导航栏项目时用户选择显示在我的传说DIV,它具有0.75的不透明度。而我的新闻稿会在btnNewsFeed onClick时展开或者崩溃。我现在遇到的问题是让我们说当legendDiv显示时,llNewsFeed隐藏在legendDiv后面。我不知道是否有任何可能的方式来设置z-index?因为llNewsFeed应该在legendDiv前面。

任何指南?提前致谢。

回答

1

您可以使用bringToFront method像:

myView.bringToFront(); 

也阅读了本 - 定义的意见Z顺序。它可能有所帮助。

+0

你介意给我提供了一些代码示例?我必须以编程方式或通过XML文件进行设置吗? – 2014-12-03 11:22:41

+0

以编程方式。 myView.bringToFront(); – jazzyjester 2014-12-03 11:25:27

+0

非常感谢!它正在工作! – 2014-12-03 11:27:11