2014-01-07 4 views
1

코드 조각 :tools : ignore = "UselessParent"는 Android XML 레이아웃 파일의 의미는 무엇입니까?

<LinearLayout 
     android:id="@+id/fullscreen_content_controls" 
     style="?buttonBarStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center_horizontal" 
     android:background="@color/black_overlay" 
     android:orientation="horizontal" 
     tools:ignore="UselessParent" > 

     <Button 
      android:id="@+id/dummy_button" 
      style="?buttonBarButtonStyle" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/dummy_button" /> 
    </LinearLayout> 

나는 tools:ignore="UselessParent" 수단 확실하지 않다. 보푸라기가 Button이 LinearLayout으로 채워진 것을 발견하면 LinearLayout이 제거되고 Button이 부모로 이동하여 뷰 계층 구조를 효율적으로 만들 수 있다는 의미입니까? 고마워요! 귀하의 경우에는

+0

[참조 링크] (http://tools.android.com/tech-docs/tools-attributes)를 참조하십시오. 내 대답이 도움이 될 경우 대답을 수락하십시오. –

답변

6

tools:ignore="UselessParent"

이 같은 메시지를 표시 피하기 위해 IDE를 알려줍니다

을 :

이 경우를 생각해 "이 RelativeLayout의 레이아웃이나있는 LinearLayout 부모가 쓸모가"

<LinearLayout 
    android:id="@+id/detailLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

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

     <Button 
      android:id="@+id/downloadFormsButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_margin="10dp" 
      android:enabled="false" 
      android:text="@string/download_forms_button" /> 

     <TextView 
      android:id="@+id/formErrorMsg" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:padding="10dp" 
      android:textSize="16dp" > 
     </TextView> 
    </RelativeLayout> 
</LinearLayout> 

에 대해 LINT 오류 메시지가 표시됩니다.

경고 메시지가 표시되지 않게하려면 빌드 경로 -> 빌드 경로 구성 ...을 클릭하십시오. Android Lint 환경 설정에서 UselessParent를 찾아 무시할 심각도를 설정하십시오.

LINT 란 무엇입니까? 이쪽을 봐 :

http://developer.android.com/tools/help/lint.html

UPDATE :

접두사 tools:는 IDE에서 사용하는 프로젝트를 컴파일 할 때 고려 아니에요.

+0

코드를 복사하고 단계를 밟았습니다. 그리고 당신이 말한 것과 똑같은 일이 일어났습니다. 응답 스타일에 매우 감사드립니다! – lzwjava

+0

스택 오버플로가 재미 있습니다! –

0

UselessParent은 상위 레이아웃을 제거 할 수 있는지 여부를 알아 내려고하는 검사에 대한 Android lint 문제 식별자입니다.

tools:ignore="UselessParent"은 lint 메시지를 표시하지 않으려면 지정된 요소와 그 하위 요소를 검사하지 않습니다.