A ViewGroup is a special view that can contain other views, called children. The view group is the base class for layouts and views containers
Questions tagged [android-viewgroup]
223 questions
48
votes
2 answers
How to fix 'android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5035)' error in android
I have layout with child (NOT as root) element RelativeLayout and then i create ViewPager and insert it as child of my Relative layout, so it's like
+Relative Layout (root)
|
+-- Relative Layout (child)
|
+-- -- ViewPager
For now moment - all…

Dmitry Nelepov
- 7,246
- 8
- 53
- 74
40
votes
6 answers
Loop through all subviews of an Android view?
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…

Slapout
- 3,759
- 5
- 40
- 61
24
votes
2 answers
Extending RelativeLayout, and overriding dispatchDraw() to create a zoomable ViewGroup
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…

Trevor
- 10,903
- 5
- 61
- 84
18
votes
3 answers
set Toolbar height programmatically Android
I am trying to set the height of toolbar programmatically by this way:
toolbar.setLayoutParams(new Toolbar.LayoutParams(LayoutParams.MATCH_PARENT, 42));
toolbar.setMinimumHeight(42);
But it causes fatal exception with this log ->…

Veka
- 581
- 2
- 6
- 12
13
votes
4 answers
IllegalArgumentException parameter must be a descendant of this view at ViewGroup.offsetRectBetweenParentAndChild
I got following exception from one of my app user in crash logs. Unable to understand from the log trace. If anybody has some thoughts, please share.
Fatal Exception: java.lang.IllegalArgumentException
parameter must be a descendant of this view
…

Ammar
- 1,811
- 5
- 26
- 60
12
votes
3 answers
onGlobalLayout differentiate between various invocations
I have a logo view, which is a full screen fragment containing single ImageView.
I have to perform some operations after the logo image is completely visible.
Following code is used to invoke the special task
@Override
public View…

nmxprime
- 1,506
- 3
- 25
- 52
10
votes
3 answers
Create Android subviews like iOS subviews
I'm trying to programmatically (not using XML files) create custom subviews in Android (that's what I call it in iOS) that is a basically a number of basic views (labels, buttons, text fields etc) put together into a reusable subview class so I can…

Zhang
- 11,549
- 7
- 57
- 87
9
votes
3 answers
Measure Recyclerview before it appears
I am currently experiencing an issue when measuring a recyclerView before it appears. I need the measuredHeight in order to start an "expand" animation.
This was previously done for a gridView in the code I'm working on and I am trying to migrate…

Loïc
- 353
- 2
- 10
8
votes
1 answer
Unable to set layout width, height and weight of inflated view in XML in Android
I am developing an Android app. In my app, I need to inflate list of views dynamically. I added them and working. The problem is with setting the width and height of layout. Now I will demonstrate my problem with a simple project. Actually, my…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
8
votes
1 answer
parent.getContext within RecyclerView.Adapter's onCreateViewHolder method
I have a custom fragment which is attached to my MainActivity. The layout file of the fragment contains the recyclerview widget.
fragment_main.xml:

Michael S.
- 93
- 1
- 1
- 5
8
votes
2 answers
What is the purpose of FrameLayout and in which scenario should we use it?
What purpose does FrameLayout serve in Android? Is there any specific scenario for which it is designed for?
In my Android application, I have a scenario where I have to show two ImageViews, one over the other. This is a .png image file with a…

Ankit
- 4,426
- 7
- 45
- 62
7
votes
2 answers
What is this blue shadow called?
What is this blue shadow called which apears when the view is pulled after it ends? is there a listener triggered when this appears or goes?
I have implemented https://github.com/maurycyw/StaggeredGridView and I want to load more items when this…

Rishabh Srivastava
- 3,683
- 2
- 30
- 58
6
votes
0 answers
Repeatedly altering visibility of a child view and measuring parent view causes wrong results in measured size and display
Why is it that when you repeatedly alter the visibility of a child view that is contained within a parent view and measure the parent view, Android returns wrong results?
I created a simple test: an XML file with only one ConstraintLayout and two…

Richard
- 7,037
- 2
- 23
- 76
6
votes
1 answer
add Dynamic child views vertically to ConstraintLayout
Android ViewGroup has the following methods to add (child) Views:
I know we can easily define horizontal/vertical orientation to LinearLayout in xml/programatically and add child views, eg.
Similarly with RelativeLayout, we can use ViewGroup's…

Nike15
- 544
- 3
- 16