2014-12-22 2 views
0

나는 다른보기를 완전히 회색으로 덮고있는보기를 만들기 위해 노력하고 있습니다. 그래서 RelativeLayout을 사용하여 약간 투명한 색을 가진 뷰를 추가했습니다. 그러나, 비록 "fill_parent"를 사용하고 있지만, 맨 위의 뷰는 0 개의 높이를 차지합니다. 예를 들어 TextView로 변경하면 wrap_content만큼 많은 공간을 차지합니다. 내 뷰를 전체 뷰의 맨 아래에 표시하려면 어떻게해야합니까 (크기가 다를 수 있음)? 내 실제 코드 :다른보기를 완전히 덮어보기

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/unit_entry" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingBottom="3dip"> 

    <include layout="@layout/view_stats" 
     android:id="@+id/unit_stats" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 


    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_below="@id/unit_stats"> 

     <LinearLayout 
      android:layout_weight="1" 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

      <include layout="@layout/view_heading_value_text" 
       android:id="@+id/unit_exp_layout"/> 

      <TextView 
       android:id="@+id/unit_skills_text" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:hint="@string/skills_injuries_hint" 
       android:background="@drawable/border"/> 

     </LinearLayout> 

     <TextView 
      android:id="@+id/unit_equipment_text" 
      android:layout_weight="1" 
      android:layout_width="0dip" 
      android:layout_height="fill_parent" 
      android:hint="@string/equipment_hint" 
      android:background="@drawable/border"/> 

    </LinearLayout> 

    <View android:id="@+id/unit_overlay" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:background="@color/gray_overlay" 
     /> 
</RelativeLayout> 

예 내가 원하는 것을 설명하기 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/unit_entry" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingBottom="3dip"> 


    <TextView 
     android:id="@+id/text1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="text1"/> 

    <TextView 
     android:id="@+id/text2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/text1" 
     android:text="text2"/> 

    <View android:id="@+id/unit_overlay" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:background="#88666666" 
     /> 
</RelativeLayout> 

이 예제에서는 내가 unit_overlay이 텍스트 1, 텍스트 2를 모두 포함 할 것이다.

+0

당신도 당신의 포함 레이아웃을 게시 할 수 있을까요? 왜냐하면 나는이 코드를 사용할 수 없기 때문이다. .. –

+0

왜 안드로이드 : orientation = "vertical"이 보이지? – TheRedFox

+0

@ FarukYazıcı 더 쉽게 테스트 할 수있는 예제가 추가되었습니다. – schoel

답변

2

다음은 두 번째 예에 대한 질문에 대한 답변입니다.

  1. 다음과 같이
  2. View '는의가 정렬 매개 변수를 조정 ID로 레이아웃에 TextView들 넣어; 이렇게함으로써

android:layout_alignLeft="@+id/texts" 
android:layout_alignRight="@+id/texts" 
android:layout_alignTop="@+id/texts" 
android:layout_alignBottom="@+id/texts" 

, 당신은 다른 레이아웃의 경계를 유지하기 위해 해당 뷰를 강요하고 있습니다. 테스트 가능한 예제의 전체 코드는 다음과 같습니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/unit_entry" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingBottom="3dip" > 

    <LinearLayout 
     android:id="@+id/texts" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/text1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="text1" /> 

     <TextView 
      android:id="@+id/text2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/text1" 
      android:text="text2" /> 
    </LinearLayout> 

    <View 
     android:id="@+id/unit_overlay" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/texts" 
     android:layout_alignRight="@+id/texts" 
     android:layout_alignTop="@+id/texts" 
     android:layout_alignBottom="@+id/texts" 
     android:background="#88666666" /> 

</RelativeLayout> 

그냥이 시도하고 당신은 단지 텍스트를 :) 커버 볼

0

제가 적용해야 하나는 코드에서보기 모를,하지만 일반적으로 당신이 원하는하는 것은 다음과 같이 이루어집니다 :

첫째, 별도의 RelativeLayout의에 포함 할 뷰를 넣어 : 다음

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

    <View 
     android:layout_height = "@+id/covering_view" 
     android:background = "@color/ /*the grey-out color here */" 
     android:layout_height = "match_parent" 
     android:layout_width = "match_parent" /> 

    /* Your view which you want to cover */ 

</RelativeLayout> 

그리고

당신이 회색 아웃 또는 ungrey 아웃보기를 원할 때보기가 :-) 지금있는 곳으로이를 넣어 간단하게

도 :-) covering_view보기의 visibility 변경

귀하의 예를 들어 다음과 같이 오버레이보기를 변경해보십시오.

<View android:id="@+id/unit_overlay" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:background="@color/gray_overlay" 
    /> 
+0

RelativeLayout은 목록의 항목입니다. 엔트리를 덮을 커버링보기 (예 : unit_entry라는 전체 RelativeLayout) – schoel

+0

대답 – Kelevandos

+0

match_parent와 fill_parent를 모두 업데이트하면 뷰의 높이가 0이됩니다. – schoel

관련 문제