[안드로이드/Android] tool attribute
안드로이드를 개발할 때, xml 파일에서 기본적으로 자주 보는 친구가 있다.
xmlns:tools="http://schemas.android.com/tools" |
딱히 문제도 안터지고 무시하고 넘어가려고 하는데,
tools:ignore="MissingConstraints" |
카메라 권한 설정 정보를 확인받기 위해서 "uses-permisstion", "uses-feature" 사용중에, 자꾸만 이 친구를 무시하라고 에러가 뜬 것이 신경쓰여 한번 알아보기로 했다.
tools은 무슨 기능을 하는 친구일까?
유용한 tools의 attribute
- tools:text
텍스트가 어떻게 나오는지 확인하여 xml의 layout preview에서 확인할 수 있고, 실제 앱에서 표시되지 않음
- tools:visibility
2개의 View가 겹칠 때, 아래의 View가 안보일때 사용
- tools:listitem(tools:listheader , tools:listfooter)
내가 넣으려고 하는 row들이 어떻게 보여질지 미리 확인 가능
- tools:layout
xml에서 fragment를 사용하는 경우 preview에서 회색화면으로 fragment의 영역을 보여주는 반면,
fragment에 보여주려는 layout을 지정하면 어떻게 보여지는지 미리 확인
- tools:showIn(<-> tools:layout)
어떻게 어울려지는지
- tools:locale
영어가 아닌 언어를 써줄 때, 스펠링이 틀렸다고 안내하는데 특정국가의 string이라는 것을 알려줌
ex) tools:locale="fr" (프랑스 언어라는 것을 알려줌)
- tools:context
이 xml이 어떤 attribute와 연관이 있는지 알려주어, 추천창을 띄어줌
- tools:ignore
MissingTranslation Lint 에러 꺼주기
- tools:targetApi(@TargetApi annotaion)
GridLayout 사용할 때 minsdkVersion이 14보다 아래일 경우 문제가 발생하기에 14임을 명시에 14에서만 앱이 동작하게 유도함
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="14" >