Linked Questions
117 questions linked to/from View's getWidth() and getHeight() returns 0
0 votes
3 answers
951 views
Dynamically call function after loading the View
I am new in android. My program has setContentView(R.layout.popup). The xml file contains a button. I need the position of the button. For this I am using btn_obj.getX but it returns 0. I think I am ...
1 vote
1 answer
1k views
Kotlin anonymous class this
I am using the sample code in this question(getWidth() and getHeight() of View returns 0). It had the following code, view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver....
0 votes
1 answer
2k views
get ConstraintLayout height and width
I want to make a method that computes the margin values based on the parent's height and width. The code below outputs -1 for both height and width. How can I get the parent's height and width ...
-1 votes
1 answer
1k views
getHeight() of a view always returns zero?
I want to check if soft keyboard is visible on screen. For that I found a code and tried it as given . But both activityRootView.getRootView().getHeight() and activityRootView.getHeight() returns ...
1 vote
3 answers
963 views
Where in the lifecycle of my Android app should I get width and height of image view?
private void getPicDetails() { targetW = img_cow.getWidth(); targetH = img_cow.getHeight(); Log.e("targetW: ", "" + targetW); Log.e("targetH: ", "" + ...
-1 votes
1 answer
2k views
How to get Width and height of item in the drawable?
I am trying to declare and initialize a variable globally as final, this variable should holde thewidth and the height of an element in the drawable, how to achieve that. I want smothing like the ...
6 votes
0 answers
1k views
How do I get the actual width, height, top, bottom, etc of a view inside a ConstraintLayout?
When a view inside a ConstraintLayout is set up with android:layout_width="0dp" and android:layout_height="0dp" so that the constraints set in app:layout_constraintLeft_toLeftOfand the likes are ...
2 votes
3 answers
1k views
Android Gridview not showing view at position 0 well
I'm new to android development and I'm facing a small difficulty regarding the GridView. I have a Gridview in my first class called Game and I added a BaseAdapter called GameAdapter. The code is ...
1 vote
1 answer
1k views
How to access a specific item within a GridView / array (in an Android app)
Writing an Android app in Android Studio, I've got a GridView to display a set of images / text and I'm having trouble working out how to access a specific item within the list. If I tap on an item, ...
1 vote
5 answers
611 views
Change width of view dynamically doesn't work
I divide the main layout to 4 sections. First part is a image view that has the layout_weight="2" and two linear layouts with the layout_weight="1" for each one. in every linear layouts there are 2 ...
0 votes
1 answer
2k views
Wait till the view is fully updated: How to?
I'm inflating a ViewGroup for export into a PDF document. After inflating it from xml file I am filling it with images and texts. Now when I try to draw this ViewGroup in the canvas of a PDF page, the ...
0 votes
2 answers
938 views
TextView - Move view to end
I have a TextView with multiple lines. How can I determine the space at the end to know if a view fits in there? Example: -------------------- | I am a multiline | | text that has | | space at ...
0 votes
2 answers
864 views
When To Get a Custom View's Width and Height Properties
I have a Class called LineGraphView which is a subclass of View. I want to be able to pass some data to this view so that it can then draw accordingly in its onDraw() method. Analysis Fragment (Where ...
0 votes
2 answers
676 views
imageView return getWidth zero
My imageView in xml: <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/ivManagePhoto" ...
1 vote
1 answer
679 views
Get image width after change visibility from gone
I has constraint layout with ImageView inside it: <ImageView android:id="@+id/iv_lottery" android:layout_width="0dp" android:layout_height="wrap_content" android:...