android merge set background not work
2013-10-30 13:30
435 查看
Recently,in a project, I try to set a merge labels's background property, the result is: background not showing up. After Checked out on the Internet, I find out what the merge label is.
Create a new HelloWorld android project, the layout file code is as follows:
Everything was ok, the RelativeLayout's parent layout's id was "content".
When we replace RelativeLayout to Merge, the result code below:
check out the layout:
You will find merge label disappeared, yes, it is this role, the whole layout which inside of the merge label was directly attached to its parent layout. So one layout is omitted, there will be performance boost! The google Phone APK use a lot of merge.
Back to the title, you know why the Set Background invalid. When rendering layout, it does not exist. And that is not only the background, any such margin, padding attributes are also not work in merge label.
http://www.easycpp.com/?p=20
Create a new HelloWorld android project, the layout file code is as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> </RelativeLayout> check out the layout:
Everything was ok, the RelativeLayout's parent layout's id was "content".
When we replace RelativeLayout to Merge, the result code below:
<merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> </merge>
check out the layout:
You will find merge label disappeared, yes, it is this role, the whole layout which inside of the merge label was directly attached to its parent layout. So one layout is omitted, there will be performance boost! The google Phone APK use a lot of merge.
Back to the title, you know why the Set Background invalid. When rendering layout, it does not exist. And that is not only the background, any such margin, padding attributes are also not work in merge label.
http://www.easycpp.com/?p=20
相关文章推荐
- Android SetBackGroundColor not working
- android setBackgroundColor
- textView.setText() 的时候报错 android.content.res.Resources$NotFoundException: String resource ID #0x0
- Android -- setWillNotDraw()
- android adb driver can not work on WINDOW XP, it take me 1 hour to fix it up
- 【Android】解决Gradle project sync failed.Basic functionality(e.g. editing,debugging) will not work prop
- android中setBackgroundColor()中不能设置背景颜色的问题
- Android图片setBackgroundResource和setImageResource的区别
- running ANDROID - ERROR - "__bionic_open_tzdata_path: ANDROID_DATA not set!"
- android&nbsp;setBackgroundColor
- AS升级3.1 编译报错:The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin.
- Android 4.3 Back key not work.
- asm.jar使用不了,Error:Could not find adb, please install Android SDK and set path to adb
- Android中使用setBackgroundDrawable错误提示:The method setBackgroundDrawable(Drawable) from the type View is
- android 4.0 兼容性问题 java.lang.NoSuchMethodError TextView.setBackground
- Warning: Could not merge cells C9-D9 as they clash with an existing set of merged cells.
- netbeans 创建android出错 build.xml:82: Android Target is not set.
- android中setBackgroundColor()中不能设置背景颜色的问题
- 【Android基础】setTextColor(),setBackgroundColor的参数设置方式
- “Location of the Android SDK has not been set up in the preferences”问题的解决