2013-08-22 161 views
-1

点击布局,显示半透明橙色层。 在布局中,有按钮,按钮可以点击,但不需要显示橙色层。 如何实现? 这是正确的吗?像Google Play一样的卡片布局

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:background="@android:color/white" 
     android:orientation="vertical" > 
     <TextView 
      android:id="@+id/tv_position" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="@android:color/white" 
      android:text="position1" 
      android:textSize="20sp" 
      /> 
     <Button 
      android:id="@+id/button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button" 
      /> 
    </LinearLayout> 
<!-- the orange layer --> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="10dp" 
     android:background="@drawable/selector_translucent_orange" 
     > 
    </RelativeLayout> 
</FrameLayout> 

,并似乎selector_translucent_orange.xml

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:drawable="@color/trans_orange" android:state_pressed="true"></item> 
    <item android:drawable="@android:color/transparent"></item> 

</selector> 

回答

0

从你的问题,你需要选择你的线性布局。如果这是真的

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:background="@drawable/selector_translucent_orange" 
    android:orientation="vertical" > 
    <TextView 
     android:id="@+id/tv_position" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="@android:color/white" 
     android:text="position1" 
     android:textSize="20sp" 
     /> 
    <Button 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" 
     /> 
</LinearLayout> 
+0

谢谢,但不是这个。 – fatsoon

+0

我的意思是像新的Youtube应用程序卡布局。 – fatsoon