Questions tagged [viewgroup]

ViewGroup is a subclass of the Android View class(parent of all Android graphical widgets) which can contain child views.

ViewGroup is the base class for all Android layouts and views containers. This class is designed to be extended so the user can implement his own layout(which arranges the children following the desired logic, one not covered by the standards layouts) or a new view container. More information about the ViewGroup class can be found at the links below:

503 questions
96
votes
11 answers

Difference between View and ViewGroup in Android

What is the difference between a View and a ViewGroup in Android programming?
user3927549
  • 1,005
  • 1
  • 7
  • 3
74
votes
11 answers

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

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…
M2014
  • 1,094
  • 1
  • 9
  • 16
66
votes
18 answers

Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error

I have a ListView with some focusable components inside (mostly EditTexts). Yeah, I know this isn't exactly recommended, but in general, almost everything is working fine and the focus goes where it has to go (with a few tweaks I had to code).…
dmon
  • 30,048
  • 8
  • 87
  • 96
54
votes
2 answers

Android Custom Layout - onDraw() never gets called

public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableView tv = new TableView(this); tv.setLayoutParams(new…
Ofek Ron
  • 8,354
  • 13
  • 55
  • 103
53
votes
10 answers

Fixed aspect ratio View

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…
Jani
  • 1,088
  • 1
  • 10
  • 18
49
votes
6 answers

Using with in ConstraintLayout

I am having trouble using tags and inside a ConstraintLayout. I want to create a flat view hierarchy (hence Constraints) but still have elements that are reusable. So I use in my layout and in the included…
JDenais
  • 2,956
  • 2
  • 21
  • 30
48
votes
1 answer

Android: get Viewgroup from the view?

Is there any way to get the ViewGroup from a view? I'm trying to create a custom array adapter and it needs the viewgroup
user2532233
  • 831
  • 2
  • 9
  • 13
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
35
votes
1 answer

Why go for Constraints layout as we already have Relative Layout?

Why RelativeLayout replaced to ConstraintLayout in the default layout file of an android empty activity. I need to know why we should use ConstraintLayout, what other benefits it provides to us.
23
votes
2 answers

Custom ViewGroup focus handling

Let's say I have a custom ViewGroup which is focusable and has some child views which are focusable as well (A custom vertical menu for Android set-top-boxes which should react on remote controller). I need to pass a focus to some of the child…
traninho
  • 1,533
  • 12
  • 19
23
votes
2 answers

Use of dispatchDraw(Canvas canvas)

What is the use of dispatchDraw(Canvas canvas) method in ViewGroup class??
Favas Kv
  • 2,961
  • 2
  • 28
  • 38
22
votes
4 answers

How to use addView to add view to layout?

I have read probably all posts and documentation but I still can't solve this issue. I want to use addView() method to add view to the existing (running) layout but for some reason I cant. I know that this should be easy and basic but still I cant…
Majstor
  • 859
  • 1
  • 12
  • 22
20
votes
2 answers

Views inside a custom ViewGroup not rendering after a size change

I'm running into a problem that has me stumped and I was hoping someone could give me some pointers. I'm working on an application that uses a custom ViewGroup (actually a FrameLayout that contains a RelativeLayout) to render an event calendar. The…
Michael Sims
  • 948
  • 6
  • 9
16
votes
4 answers

generating a LayoutParams based on the type of parent

I find myself needing to create a View completely in Java without knowing what concrete type the parent is. example: public View getView(int position, View convertView, ViewGroup parent){ if(null == convertView){ convertView = new…
keyboardr
  • 841
  • 1
  • 8
  • 20
16
votes
2 answers

custom ViewGroup example?

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…
speeder
  • 6,197
  • 5
  • 34
  • 51
1
2 3
33 34