2017-09-13 111 views
0

我是一个新的程序员,我试图在另一个布局上添加一个优胜者布局,但赢家布局变得透明(在游戏布局的后面) 我不是肯定如何解决这个问题.. 赢家布局的设计是从另一个布局,我没有这种问题 任何想法我怎么能解决这个问题? my problem在另一个布局的顶部添加布局

messageForWinnerLayout.setVisibility(linearLayout.VISIBLE); 
<LinearLayout 
    android:id="@+id/messageForWinnerLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:layout_marginLeft="40dp" 

    android:layout_marginRight="40dp" 
    android:layout_marginTop="100dp" 

    android:background="@drawable/layout_bg" 
    android:orientation="vertical" 
    android:visibility="invisible"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="20dp" 
     android:layout_marginTop="10dp"> 

     <ImageView 
      android:id="@+id/closeImage" 
      android:layout_width="60dp" 
      android:layout_height="60dp" 
      android:layout_marginLeft="250dp" 
      android:onClick="ok" 
      app:srcCompat="@drawable/x" /> 
    </RelativeLayout> 

    <TextView 
     android:id="@+id/haveWinnerTitle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:gravity="center_horizontal" 
     android:text="We Have A Winner!" 
     android:textColor="@android:color/black" 
     android:textSize="18sp" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/winnerMsg" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:gravity="center_horizontal" 
     android:textColor="@android:color/black" 
     android:textSize="18sp" /> 

    <Button 
     android:id="@+id/closeButton" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="100dp" 
     android:layout_marginRight="100dp" 
     android:layout_marginTop="5dp" 
     android:background="@android:color/holo_blue_dark" 
     android:text="Close" 
     android:textColor="@android:color/white" 
     android:textSize="18sp" /> 

</LinearLayout> 
+0

你为什么不使用'view.setVisibility(View.GONE)'? – Gotiasits

回答

0

你可以尝试使用父布局RelativeLayout的,通过使用RelativeLayout的,我们可以在顶部的另一个子视图添加视图。

相关问题