2014-12-28 2 views
0

나는 일하고 인터넷 검색을 한동안하고 난처한 것 같습니다.보기 setlook 이상한 행동

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

    <include layout="@layout/swipe_hint" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true"/> 
    ... other views 
</RelativeLayout> 

레이아웃 swipe_hint 그래서 다음과 같습니다 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/swipe_hint_layout" 
       android:visibility="gone" 
       android:orientation="vertical" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

    ... more views 
지금 자바 코드에 내가 지금처럼 독립적으로 알파를 변경하려고 :

이 내 조각의보기이다
// this fragment's view is the first xml layout above 
View pageOneLayout = fragment.getView(); 
// get the layout of the swipe hint through the fragment's view since it is included 
View swipeView = pageOneLayout.findViewById(R.id.swipe_hint_layout); 

// here is where I run into problems 
pageOneLayout.setAlpha(.25f); 
swipeView.setAlpha(1); 

pageOneLayout 알파를 .25로 설정하면 전체 레이아웃의 알파가 변경됩니다. o 예상되는 25 %의 투명성. 그러나 swipeView에 대해 알파를 별도로 설정하면 효과가없는 것처럼 보입니다. swipeView 여전히 투명합니다 .25입니다. 이처럼 알파를 개별적으로 설정한다고 생각하면 두 가지보기에는 별도의 투명도가 적용됩니다. 그러나 이것은 그렇지 않습니다. 거기 밖으로 누군가 주제에 약간 빛을 비춰 줄 수 있 었는가 ??

답변

1

이 동작의 이유는 RelativeLayout 및 LinearLayout의 모든 자식이 부모로부터 알파를 상속받습니다.

별도의 알파 레벨을 사용하려면 FrameLayout을 사용해보십시오.

+0

하지만 상속을 통해 자녀의 알파 브레이크를 설정하지 않으시겠습니까? –

+0

0.5로 설정하여 아이가 어떻게되는지보십시오. – Nuwisam

+0

에는 상속을 해할 수있는 방법이있어서 2 가지 다른 알파 수준에서이를 사용할 수 있습니까? –