android - Warning: This <FrameLayout> can be replaced with a <merge> tag -
i have framelayout
contains textview
, 2 linearlayout
s:
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > ... textview , 2 linearlayouts </framelayout>
after running android lint, warning: this <framelayout> can replaced <merge> tag.
why warning exist? can fix (other ignore)?
to understand this, need understand how layout inflated , placed.
let's example, have activity , layout xml use. here layout of activity looks before put layout file.
<framelayout // window ... <framelayout> // activity </framelayout> </framelayout>
there might few other layers depending on device/os.
now when inflate layout file , put in, how look.
<framelayout // window ... <framelayout> // activity // layout below <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > ... textview , 2 linearlayouts </framelayout> </framelayout> </framelayout>
do see framelayout inside framelayout? redundant have since not add value. optimize, can replace framelayout < merge >. if use , like.
<framelayout // window ... <framelayout // activity // layout below ... textview , 2 linearlayouts </framelayout> </framelayout>
notice how there no framelayout. instead, merged framelayout of activity. whenever can, should use < merge >. doesn't apply framelayouts. can read more here. http://developer.android.com/training/improving-layouts/reusing-layouts.html#merge
hope helps.
Comments
Post a Comment