Android windowmanager addview9/21/2023 ![]() ![]() However this is not enough, I want to konw what happens when gravity is not set(More specifically, I want to find the code drawing the ImageView). * When using Gravity#TOP} or Gravity#BOTTOM} it provides On Fling/Swipe I need to change the view. * Gravity#END} it provides an offset from the given int x Hello, I am trying to develop a service in which a view gets displayed using WindowManager. * When using Gravity#LEFT} or Gravity#START} or Gravity#RIGHT} or In the source code of WindowManager.LayoutParams, I found that only when the gravity is set, the x and y properties will be taken into account: /** _LAYOUT_NO_LIMITS|_NOT_FOCUSABLE|_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT) The reason I ask is, Im thinking of using windowManager. WindowManager.LayoutParams params = new WindowManager.LayoutParams(60,60,_SYSTEM_ALERT, I changed: params.x newX - (topLeftLocationOnScreen 0) params.y newY - (topLeftLocationOnScreen 1) to: offsetX originalXPos - x offsetY originalYPos - y I'd be glad to hear an explanation of the topLeft code. WindowManager manager = (WindowManager) this.getSystemService(WINDOW_SERVICE) So I commented out all the topLeft / topLeftView code and it made very little difference. Img.setImageResource(android.R.drawable.ic_delete) ![]() This method is always called within the main thread of its process, unless you explicitly asked for it to be scheduled on a different thread using. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values. It appears in left-top corner only when I set the gravity property of the WindowManager.LayoutParams to Gravity.LEFT|Gravity.TOP, why? Is the default value of gravity property Gravity.CENTER? I looked into the android source code but got lost. This method is called when the BroadcastReceiver is receiving an Intent broadcast. But I found that the ImageView is in the center of the screen, not the left-top corner. Here is the problem~ I tried to add an ImageView to the window by calling the WindowManager.addView() method. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |