viewgroup

Android ViewGroup crash: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference

半腔热情 提交于 2019-11-28 17:43:28
We have found several cases for this kind of crashes reported by backend logging monitoring. It seems the crashes do not tie to particular UX failure. And from the reports, there is no sign of how our own classes being involved(no sign of any of our classes names). Here is an example of typical crashes: java.lang.NullPointerException: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3357) at android.view.View.updateDisplayListIfDirty(View.java:14288) at android.view.View.getDisplayList(View.java:14315

ViewGroup finish inflate event

孤人 提交于 2019-11-28 10:10:52
I have created a custom layout which extends ViewGroup. Everything is working fine and I am getting the layout as expected. I want to dynamically change an element in the layout. However this is not working as I am calling it in onCreate and till that time the entire layout is not actually (drawn) inflated onto the screen and hence do not have actual size. Is there any event which can be used to find out when the inflation of the layout is done? I tried onFinishInflate but that would not work as Viewgroup has multiple views and this would be called multiple times. I am thinking of creating an

How to bring a view to front without calling bringToFront()?

你说的曾经没有我的故事 提交于 2019-11-28 07:51:27
问题 There is apparently a bug in Android which breaks View.bringToFront . If I have Views arranged in a GridView and want to bring a View to front by calling bringToFront(), it may get moved to the bottom right position in the GridView. Something shady is going on there, so I can't use bringToFront(). When I don't call it, everything works fine. But the Views overlap - if I use scale animation to scale up a View, it's partially obscured by the Views to the bottom and to the right. I've checked

Loop through all subviews of an Android view?

…衆ロ難τιáo~ 提交于 2019-11-28 04:56:11
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 on the screen that respond to touch and whose status I can check? Romain Guy @jqpubliq Is right but if

custom ViewGroup example?

烂漫一生 提交于 2019-11-27 20:34:15
问题 I searched here on SO, on Google, on the android docs... But I cannot find a single snippet of code with a example of custom viewgroup, I find at most some vague explanations... Can someone provide one? How you make a viewgroup where you can put its children where you want? 回答1: I think the simplest example to look at is the source for AbsoluteLayout.java https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsoluteLayout.java You need to override onMeasure

Fixed aspect ratio View

…衆ロ難τιáo~ 提交于 2019-11-27 19:09:08
问题 How would I go implementing a fixed aspect ratio View ? I'd like to have items with 1:1 aspect ratio in a GridView . I think it's better to subclass the children than the GridView ? EDIT: I assume this needs to be done programmatically, that's no problem. Also, I don't want to limit the size, only the aspect ratio. 回答1: I implemented FixedAspectRatioFrameLayout, so I can reuse it and have any hosted view be with fixed aspect ratio: public class FixedAspectRatioFrameLayout extends FrameLayout

How to handle click in the child Views, and touch in the parent ViewGroups?

这一生的挚爱 提交于 2019-11-27 18:29:10
问题 In my layout I have a structure like that: --RelativeLayout | --FrameLayout | --Button, EditText... I want to handle touch events in the RelativeLayout and in the FrameLayout, so I set the onTouchListener in these two view groups. But only the touch in the RelativeLayout is captured. To try solve this, I wrote my own CustomRelativeLayout, and override the onInterceptTouchEvent , now the click in the child ViewGroup (FrameLayout) is captured, but the click in the buttons and other views doesn

Fixed aspect ratio View

五迷三道 提交于 2019-11-27 17:31:05
How would I go implementing a fixed aspect ratio View ? I'd like to have items with 1:1 aspect ratio in a GridView . I think it's better to subclass the children than the GridView ? EDIT: I assume this needs to be done programmatically, that's no problem. Also, I don't want to limit the size, only the aspect ratio. TalL I implemented FixedAspectRatioFrameLayout, so I can reuse it and have any hosted view be with fixed aspect ratio: public class FixedAspectRatioFrameLayout extends FrameLayout { private int mAspectRatioWidth; private int mAspectRatioHeight; public FixedAspectRatioFrameLayout

How does one Animate Layout properties of ViewGroups?

烈酒焚心 提交于 2019-11-27 14:07:47
问题 I have the following layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> <FrameLayout android:id="@+id/viewgroup_left" android:layout_height="match_parent" android:layout_weight="2" android:layout_width="0dp"> ... children ... </FrameLayout> <LinearLayout android:id="@+id/viewgroup_right" android:layout_height="match_parent" android:layout_weight="1"

Activity.addContentView(View) == ViewGroup.addContentView(View)?

丶灬走出姿态 提交于 2019-11-27 13:57:56
问题 I have a question regarding Android Activitys: An Activity has the Method addContentView(View) while a ViewGroup has a (similar?) addView(View) Method. Unfortunately its undocumented where the View from addContentView is placed. Is it like a LinearLayout just adding the View to the bottom, or is it more like a FrameLayout , which adds its Views "onTop" ? Does it depend on the ViewGroup set by setContentView ? If I dive into the sources I see that addContentView will call Window 's abstract