android-viewgroup

Loop through all subviews of an Android view?

梦想的初衷 提交于 2019-11-27 00:43:12
问题 I’m working on a game for Android. To help implement it, my idea is to create a subclass of a view. I would then insert several instances of this class as children of the main view. Each instance would handle detecting when it was pressed (via OnTouchListener). The problem I’m having now is how do I loop through all these sub-views so I can read their statuses and process them? (I.e. when they all reach a certain state something should happen). Or is there a better way to have several objects

Extending RelativeLayout, and overriding dispatchDraw() to create a zoomable ViewGroup

半世苍凉 提交于 2019-11-26 21:35:47
I've seen a few people ask how to zoom an entire ViewGroup (such as a RelativeLayout) in one go. At the moment this is something I need to achieve. The most obvious approach, to me, would be to hold the zoom scale factor as a single variable somewhere; and in each of the child Views' onDraw() methods, that scale factor would be applied to the Canvas prior to graphics being drawn. However, before doing that, I have tried to be clever (ha - usually a bad idea) and extend RelativeLayout, into a class called ZoomableRelativeLayout. My idea is that any scale transformation could be applied just

Extending RelativeLayout, and overriding dispatchDraw() to create a zoomable ViewGroup

孤人 提交于 2019-11-26 07:59:20
问题 I\'ve seen a few people ask how to zoom an entire ViewGroup (such as a RelativeLayout) in one go. At the moment this is something I need to achieve. The most obvious approach, to me, would be to hold the zoom scale factor as a single variable somewhere; and in each of the child Views\' onDraw() methods, that scale factor would be applied to the Canvas prior to graphics being drawn. However, before doing that, I have tried to be clever (ha - usually a bad idea) and extend RelativeLayout, into