lzw*_*ava 2 layout android lint
代码段:
<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>
Run Code Online (Sandbox Code Playgroud)
我不确定tools:ignore="UselessParent"手段.这是否意味着当lint发现Button填充时LinearLayout,然后LinearLayout将删除,Button将移动到父级并让视图层次结构高效?非常感谢!
在你的情况下
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>
Run Code Online (Sandbox Code Playgroud)
内部显示LINT错误消息RelativeLayout.
要避免出现警告消息,请转到Build Path-> Configure Build Path ....在Android Lint Preferences下查找UselessParent并将其严重性设置为忽略.
什么是LINT?看这里:
http://developer.android.com/tools/help/lint.html
更新:
tools:IDE使用前缀,编译项目时不考虑前缀.
| 归档时间: |
|
| 查看次数: |
7900 次 |
| 最近记录: |