共 25 篇文章 |
|
Android 对话框弹出位置和透明度的设置,最顶层窗口配置在Android中我们经常会用AlertDialog来显示对话框。就需要获得对话框的Window对象,获得这个Window对象有多种方法。Window window = alertDialog.getWindow();透明的对话框 默认显示的对话框是不透明的,但我们可以通过设置对话框的alpha值将其变成透明或半透明效果。下面的代码通过将al... 阅1963 转5 评0 公众公开 17-06-26 14:05 |
加上这篇介绍Android广播的,我的BLOG中就对Android中四大组件Activity、BroadcastReceiver、ContentProvider、Service都做了介绍,感兴趣的同学可以翻阅我之前的博客对这些内容进行了解。<activity android:name=".DilaogActivity" android:theme="@android:style/Theme.Dialog" />以上是介绍了一些基本知识和本Dem... 阅127 转0 评0 公众公开 17-05-26 08:59 |
LayoutParams mLayoutParams;LayoutParams params = new WindowManager.// 设置悬浮窗的Touch监听 btn_floatView.setOnTouchListener(new View.OnTouchListener() { int lastX, lastY; int paramX, paramY;// 更新悬浮窗位置 wm.updateViewLayout(btn_floatView, params); break; } return true; } }); wm.addView(btn_floatView, params); }vi... 阅736 转3 评0 公众公开 17-05-15 09:07 |
android:configChanges="keyboardHidden|orientation|screenSize"经过上面代码演示,我们可以看到具体实现涉及到了Manifest工程配置里面具体Activity的screenOrientation和configChanges两个参数,这两个参数screenOrientation的优先级是高于configChanges,即假如screenOrientation设置为固定横竖屏时,那么configChanges参数无论怎... 阅69 转1 评0 公众公开 17-05-14 13:58 |
我 们先来看看addView()方法,在addView中,会利用LayoutParams获得window的View属性,并为每个window创 ViewRoot,ViewRoot是View和WindowManager之间的桥梁,真正把View传递给WindowManager的是通过 ViewRoot的setView()方法,ViewRoot实现了View和WindowManager之间的消息传递。<LinearLayout xmlns:android="http://schemas.androi... 阅214 转0 评0 公众公开 17-05-11 09:09 |
1、WindowManager介绍。其实我们的Activity或者Diolog底层的实现也是经过WindowManager,WindowManager是全局的,整个系统只有一个WindowManager。我们先来看看addView()方法,在addView中,会利用LayoutParams获得window的View属性,并为每个window创ViewRoot,ViewRoot是View和WindowManager之间的桥梁,真正把View传递给WindowManager的是通... 阅879 转2 评0 公众公开 17-05-11 09:02 |
LocalWindowMangers 的生命周期小于Activity的生命周期,(因为mWindowManager是Window的成员变量,而mWindow又是Activity的成员变量),所以,如果我们在一个LocalwindowManager中手动添加了其他的图层, 在Activity的finish执行之前, 应该先调用LocalwindowManager的removeView, 否则会抛出异常。(注:如果是通过activity.getSystemService(Cont... 阅72 转1 评0 公众公开 17-05-11 08:37 |
(1)为调用的时候每次保留 canvas到bitmap中,每次刷新的时候继续使用之前的bitmap.null null null 一开始有三个为空的canvas,第一个设置的第一个会在 3的位置,但是获得的在第一个的位置,之后每次获得都是当前的三个之前,这样。就无法每次得到之前的canvas,然后在其中画图,我所做的处理是使用一个bitmap,每次将其保存在bitmap... 阅580 转1 评0 公众公开 17-03-28 13:29 |
今天在使用PopWindow.showAtLocation(View parent, int gravity, int x, int y)时,最后2个参数的传值问题,1.首先使用了View.getLocationOnScreen(new Location[]) 或者 getLocationInWindow(new Location[]);获取到的location[0]及location[1]有时为02.使用View.getGlobalVisibleRect(new Rect());获取rect.left view距屏幕左边的间距,rect.... 阅4714 转4 评0 公众公开 17-03-26 14:44 |
由于最近在写一个涉及移动方面的自定义View,在做移动的时候用到了类似offsetTopAndBottom 、setTranslationY、scrollTo、scrollBy等方法,对于他们的使用,有一些不太清晰的地方。getX getY 会变getTranslationXY会变点击事件的位置也变了但是不会超过父布局会超过边界到同层view的区域去(被覆盖或者覆盖别人--取决于先后顺序)scrollBy:offs... 阅62 转0 评0 公众公开 17-03-26 14:11 |