首页 文章 精选 留言 我的

精选列表

搜索[android things],共10000篇文章
优秀的个人博客,低调大师

Android系统的开机画面显示过程分析(4)

函数fb_show_logo_line也是实现在文件kernel/goldfish/drivers/video/fbmem.c中,如下所示: staticintfb_show_logo_line(structfb_info*info,introtate, conststructlinux_logo*logo,inty, unsignedintn) { u32*palette=NULL,*saved_pseudo_palette=NULL; unsignedchar*logo_new=NULL,*logo_rotate=NULL; structfb_imageimage; /*Returniftheframebufferisnotmappedorsuspended*/ if(logo==NULL||info->state!=FBINFO_STATE_RUNNING|| info->flags&FBINFO_MODULE) return0; image.depth=8; image.data=logo->data; if(fb_logo.needs_cmapreset) fb_set_logocmap(info,logo); if(fb_logo.needs_truepalette|| fb_logo.needs_directpalette){ palette=kmalloc(256*4,GFP_KERNEL); if(palette==NULL) return0; if(fb_logo.needs_truepalette) fb_set_logo_truepalette(info,logo,palette); else fb_set_logo_directpalette(info,logo,palette); saved_pseudo_palette=info->pseudo_palette; info->pseudo_palette=palette; } if(fb_logo.depth<=4){ logo_new=kmalloc(logo->width*logo->height,GFP_KERNEL); if(logo_new==NULL){ kfree(palette); if(saved_pseudo_palette) info->pseudo_palette=saved_pseudo_palette; return0; } image.data=logo_new; fb_set_logo(info,logo,logo_new,fb_logo.depth); } image.dx=0; image.dy=y; image.width=logo->width; image.height=logo->height; if(rotate){ logo_rotate=kmalloc(logo->width* logo->height,GFP_KERNEL); if(logo_rotate) fb_rotate_logo(info,logo_rotate,&image,rotate); } fb_do_show_logo(info,&image,rotate,n); kfree(palette); if(saved_pseudo_palette!=NULL) info->pseudo_palette=saved_pseudo_palette; kfree(logo_new); kfree(logo_rotate); returnlogo->height; } 参数logo指向了前面所准备的第一个开机画面的内容。这个函数首先根据参数logo的内容来构造一个fb_image结构体image,用来描述最终要显示的第一个开机画面。最后就调用函数fb_do_show_logo来真正执行渲染第一个开机画面的操作。函数fbcon_switch实现在文件kernel/goldfish/drivers/video/console/fbcon.c中,显示第一个开机画面的过程如下所示: staticvoidfb_do_show_logo(structfb_info*info,structfb_image*image, introtate,unsignedintnum) { unsignedintx; if(rotate==FB_ROTATE_UR){ for(x=0; x<num&&image->dx+image->width<=info->var.xres; x++){ info->fbops->fb_imageblit(info,image); image->dx+=image->width+8; } }elseif(rotate==FB_ROTATE_UD){ for(x=0;x<num&&image->dx>=0;x++){ info->fbops->fb_imageblit(info,image); image->dx-=image->width+8; } }elseif(rotate==FB_ROTATE_CW){ for(x=0; x<num&&image->dy+image->height<=info->var.yres; x++){ info->fbops->fb_imageblit(info,image); image->dy+=image->height+8; } }elseif(rotate==FB_ROTATE_CCW){ for(x=0;x<num&&image->dy>=0;x++){ info->fbops->fb_imageblit(info,image); image->dy-=image->height+8; } } } 参数rotate用来描述屏幕的当前旋转方向。屏幕旋转方向不同,第一个开机画面的渲染方式也有所不同。例如,当屏幕上下颠倒时(FB_ROTATE_UD),第一个开机画面的左右顺序就刚好调换过来,这时候就需要从右到左来渲染。其它三个方向FB_ROTATE_UR、FB_ROTATE_CW和FB_ROTATE_CCW分别表示没有旋转、顺时针旋转90度和逆时针旋转90度。 参数info用来描述要渲染的帧缓冲区硬件设备,它的成员变量fbops指向了一系列回调函数,用来操作帧缓冲区硬件设备,其中,回调函数fb_imageblit就是用来在指定的帧缓冲区硬件设备渲染指定的图像的。 至此,第一个开机画面的显示过程就分析完成了。 本文转自 Luoshengyang 51CTO博客,原文链接:http://blog.51cto.com/shyluo/967032,如需转载请自行联系原作者

优秀的个人博客,低调大师

android开发—Fragment中onCreateView()和onActivityCreated()的区别

在编写Fragment时,在onCreateView()方法中启动了一个初始化自定义View的方法 initView(),但是调试时就崩溃,打印日志发现是这里出了问题,就将这个方法放到了onActivityCreated()方法中启动,就没有再崩溃过,不明白为什么,查询API和资料后总结如下:书上的讲解是:onCreateView():每次创建、绘制该Fragment的View组件时回调该方法,Fragment将会显示该方法返回的View组件。onActivityCreated():当Fragment所在的Activity被启动完成后回调该方法。 API: 而上文出现的问题是这样的: ①静态的view不需要onActivityCreated ②保存view的状态的时候需要用onActivityCreated ③访问父activity的view层的时候需要在onActivityCreated 方法里面做 即如果view是静态的,那么没有必要在onActivityCreated 方法去调用,大多数的自定义的view,初始化时都需要一个context,而activity是context的子类,所以在onCreateView方法的时候非静态的view初始化调用可能出现异常,所以对于非静态的view,最好在onActivityCreated方法调用 参考了以下两篇博客:http://blog.csdn.net/u014449046/article/details/48572905http://blog.csdn.net/lxl403853563/article/details/49800231 本文转自 一点点征服 博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/5591988.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android笔记: 解决ScrollView嵌套ListView的冲突方法

范例: 1.MainActivity代码: 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 public class MainActivity extends Activity { // 只要在设置ListView的Adapter后调用此静态方法Utility.setListViewHeightBasedOnChildren(listview); // 即可让ListView正确的显示在其父ListView的ListItem中。 // 但是要注意的是,子ListView的每个Item必须是LinearLayout,不能是其他的,因为其他的Layout(如RelativeLayout) // 没有重写onMeasure(),所以会在onMeasure()时抛出异常。 private ArrayList<String> dataList; private ListView listview; private ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataList = new ArrayList<String>(); for ( int i = 0 ; i < 5 ; i++) { String str = "第" + i + "行" ; dataList.add(str); } img = (ImageView) findViewById(R.id.imageView1); listview = (ListView) findViewById(R.id.listView1); listview.setAdapter( new BaseAdapter() { @Override public View getView( int position, View convertView, ViewGroup parent) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.item, null ); TextView tv = (TextView) layout.findViewById(R.id.tv_item); String str = dataList.get(position); tv.setText(str); return layout; } @Override public long getItemId( int position) { return 0 ; } @Override public Object getItem( int position) { return null ; } @Override public int getCount() { return dataList.size(); } }); Utility.setListViewHeightBasedOnChildren(listview); } } 2.Utility代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null ) { // pre-condition return ; } int totalHeight = 0 ; for ( int i = 0 ; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null , listView); listItem.measure( 0 , 0 ); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1 )); listView.setLayoutParams(params); } } 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1290605,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册