viewStub

Not able to access ViewStub'child

此生再无相见时 提交于 2019-12-01 16:22:23
问题 I am trying to use VIEWSTUB inside the merge tag.and its working well.I'm able to catch onclicklistenr of ViewStub's parent button.But i want to access the button that is inside the viewstub. 1.Main xml: <merge> <LinearLayout> <Button></Button> <ViewStub></ViewStub> </LinearLayout> </merge> 2.view stub layout <Button android:id="@+id/button_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="100dip" android:text="Next" /> <ImageView android

How many ViewStubs is too many for a single layout XML file?

橙三吉。 提交于 2019-11-30 20:28:43
I have a layout defined in an XML file( base_layout.xml ) which may contain 20+ ViewStub definitions in addition to 3-5 other views such an ImageView and a LinearLayout containing 3-5 ImageButton views. Should i be concerned about how many ViewStub views i place in this layout file? I read on the developer.android site: A ViewStub is a dumb and lightweight view. It has no dimension, it does not draw anything and does not participate in the layout in any way. This means that a ViewStub is very cheap to inflate and very cheap to keep in a view hierarchy is it cheap enough to have 20+ of them?

Difference between <include> and <ViewStub> in android

只谈情不闲聊 提交于 2019-11-30 17:13:17
What are the differences between <\include> tag and <\ViewStub> tag and which one is preferrable while designing the layout. Thanks, venu Gregory The < include /> will just include the xml contents in your base xml file as if the whole thing was just a single big file. It's a nice way to share layout parts between different layouts. The < ViewStub /> is a bit different because it is not directly included, and will be loaded only when you actually use it/need it, ie, when you set its visibility to VISIBLE (actually visible) or INVISIBLE (still not visible, but its size isn't 0 anymore). This a

How many ViewStubs is too many for a single layout XML file?

独自空忆成欢 提交于 2019-11-30 04:48:29
问题 I have a layout defined in an XML file( base_layout.xml ) which may contain 20+ ViewStub definitions in addition to 3-5 other views such an ImageView and a LinearLayout containing 3-5 ImageButton views. Should i be concerned about how many ViewStub views i place in this layout file? I read on the developer.android site: A ViewStub is a dumb and lightweight view. It has no dimension, it does not draw anything and does not participate in the layout in any way. This means that a ViewStub is very

Difference between <include> and <ViewStub> in android

蓝咒 提交于 2019-11-30 00:39:32
问题 What are the differences between <\include> tag and <\ViewStub> tag and which one is preferrable while designing the layout. Thanks, venu 回答1: The < include /> will just include the xml contents in your base xml file as if the whole thing was just a single big file. It's a nice way to share layout parts between different layouts. The < ViewStub /> is a bit different because it is not directly included, and will be loaded only when you actually use it/need it, ie, when you set its visibility

How to use View Stub in android

不打扰是莪最后的温柔 提交于 2019-11-28 17:43:56
I want to use ViewStub in android, so please help me. I have created ViewStub stub = new ViewStub; View inflated = stub.inflate(); How to use it programmatically? Like the documentation says, ViewStub is a View that is inflated lazily. You can declare a ViewStub in an XML file like this: <ViewStub android:id="@+id/stub" android:inflatedId="@+id/subTree" android:layout="@layout/mySubTree" android:layout_width="120dip" android:layout_height="40dip" /> The android:layout attribute is a reference to the View that will be inflated next to a call of inflate() . So ViewStub stub = (ViewStub)

Android性能优化之布局优化篇

谁说胖子不能爱 提交于 2019-11-27 13:46:45
怎样才能写出优秀的Android App,是每一个程序员追求的目标。那么怎么才能写出一个优秀的App呢?相信很多初学者也会有这种迷茫。一句话来回答这个问题:细节很重要。今天我们就从最基础的XML布局来谈谈怎么提高Android性能问题吧! 也许你经常会遇到比较复杂的布局,这种情况下,最简单的方法就是多层嵌套实现效果,但是最简单的方法是否是最优的方法呢? 这里需要打一个大大的问号?????经验告诉我们,往往简单的方法,得到的结果不是最优解,那么我们通过一个例子来研究一下怎么去优化我们的XML布局吧,下面通过经典微信中的“发现”tab页面中的布局来看看怎么实现。 上面这张图片是微信界面截图,看到这张效果图的第一眼会让开发者想到使用线性布局实现这种左边图片,右边文字,一行白色背景效果很方便。那么我们就按照一般思路写出如下布局代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

【学习笔记】Android性能优化----->布局优化

本秂侑毒 提交于 2019-11-27 13:46:25
1.AndroidUI渲染机制 人眼所感觉的流畅画面,需要画面的帧数达到40帧每秒到60帧每秒 在Android中,系统通过VSYNC信号触发对UI的渲染/重绘,其间隔时间是16ms,这个16ms其实就是1000ms中 显示60帧画面的单位时间,即1000/60 如果系统每次渲染的时间都保持在16ms之内,那我们看见的UI界面将是非常流畅的 但这也就需要将所有程序的逻辑都保证在16ms之内 如果不能在16ms内完成绘制,那么就会造成丢帧现象,即当前该重绘的帧被未完成的逻辑阻塞 例如一次绘制任务耗时20ms,那么在16ms系统发出VSYNC信号时就无法绘制,该帧就被丢弃,等待下次信号才开始绘制, 导致16*2ms内都显示同一帧画面,这就是画面卡顿的原因 Android系统提供了检测UI渲染时间的工具,打开“开发者选项”,选择“Profile GPU Rendering”, 并选中“On screen as bars”的选项,这时候在屏幕上将显示一些条形图。 每一条柱状线包含三部分:蓝色代表测量绘制Display List的时间,红色代表OpenGL渲染Display List所需要的时间, 黄色代表CPU等待GPU处理的时间。 中间的绿色横线代表VSYNC时间16ms,需要尽量将所有条形图都控制在这条绿色之下。 2.避免Overdraw Overdraw,过度绘制会浪费很多的CPU

Android的布局复用与优化

可紊 提交于 2019-11-27 01:53:39
在布局优化中,Android的官方提到了这三种布局<include />、<merge />、<ViewStub />,并介绍了这三种布局各有的优势,下面也是简单说一下怎么使用. 1、布局重用<include /> <include />标签能够重用布局文件,简单的使用如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width=”match_parent” android:layout_height=”match_parent” android:background="@color/app_bg" android:gravity="center_horizontal"> <include layout="@layout/layout_title"/> <TextView android:layout_width=”match_parent” android:layout_height="wrap_content" android:text="@string/hello" android:padding="10dp" /> ... </LinearLayout> 1)<include /

使用viewstub实现嵌套布局

泄露秘密 提交于 2019-11-27 00:34:16
Viewstub的使用是比较简单的。他就仿佛是个layout。然后把其他的布局文件看作是一个view标签 然后把这些view标签往这个layout中填充, 当然 这个layout也可以有自己的布局方式 所以我把他理解成为嵌套布局。 源码下载地址: http://zhengxdstudy.googlecode.com/svn/trunk/zhengxdstudy/viewstub 效果图 viewstub布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ViewStub android:id = "@+id/stub_import" android:inflatedId = "@+id/panel_import" android:layout = "@layout/index" 指定index.xml布局文件 android:layout_width = "fill_parent"