simulate the view still being present by providing an image of view
来源:互联网 发布:为什么脸会变宽 知乎 编辑:程序博客网 时间:2024/06/14 00:16
sometime,we can not avoid a view disappearing,for example: nested fragment will be disappeared when the parent fragment is removed/replaced,
in order to avoid the user seeing the nested fragment disappearing,you could simulate those fragments still being present by providing an image of them,
as they appeared on the screen. this image will be used as a background for the nested fragments containerso even if the views of the nested fragment go away the image will simulate their presence.
the following code was a little example with setting up the background image
public static class FragmentA extends Fragment {private Bitmap b = null;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);getChildFragmentManager().beginTransaction().add(android.R.id.list, new FragmentA1()).add(android.R.id.list, new FragmentA2()).commit();}@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {LinearLayout layout = new LinearLayout(container.getContext());layout.setBackgroundColor(Color.RED);layout.setOrientation(LinearLayout.VERTICAL);layout.setId(android.R.id.list);return layout;}@Overridepublic void onPause() {b = loadBitmapFromView(getView());super.onPause();}public static Bitmap loadBitmapFromView(View v) {Bitmap b = Bitmap.createBitmap(v.getWidth(),v.getHeight(), Bitmap.Config.ARGB_8888);Canvas c = new Canvas(b);v.layout(0, 0, v.getWidth(),v.getHeight());v.draw(c);return b;}@Overridepublic void onDestroyView() {BitmapDrawable bd = new BitmapDrawable(b);getView().findViewById(android.R.id.list).setBackground(bd);b = null;super.onDestroyView();}}
0 0
- simulate the view still being present by providing an image of view
- 1.4 Dynamically change the look of an application by using view states,transitions and effects
- by uninstalling an existing version of the apk if it is present,
- Hint: This may be the result of an unspecified view, due to default view name generation.)]
- How to provide an alternative view of data by using a splitter window
- 1.View the Exhibit and examine the attributes of an undo tablespace.
- image view
- Android TV -2.2- Providing a Card View
- Changing The Size Of An Image
- The Relational View of Data
- How to programmatically change the default view of an InfoPath form
- Dismiss keyboard by touching background of view
- The Imminent Demise of the Page View
- The view of the C language
- The view of the C++ language
- In the exotic view of the city
- the english of the simple view
- Simulate the pressing of keyboard keys
- Android之数据上传tomcat服务器
- Office365 sharepoint online 如何设置匿名访问
- Javascript中正则表达式的全局匹配模式
- 运算符
- SpringMVC框架介绍
- simulate the view still being present by providing an image of view
- Extjs4.2边学边用之Controller()
- virtualbox 磁盘大小调整
- Php实现验证码功能
- 趣味编程:静夜思(Javascript版)
- U盘安装CentOS 7的方法
- zoj3798Abs Problem(思维)
- 安装mysql5.7,不能下载Connector/ODBC 5.3.2
- python 的一些有趣用法