Questions tagged [android-viewtreeobserver]
39 questions
1
vote
1 answer
ViewTreeObserver.OnWindowFocusChangeListener in a service
How to implement ViewTreeObserver.OnWindowFocusChangeListener in a service in Android . The code does not show any type of error when i use it in my java file .
Is there any other way to use OnWindowFocusChangeListener in a service ?
Please help…

perhaps 2me
- 13
- 4
1
vote
1 answer
Xamarin.Android, How to unsubscribe from View Tree Observer in
I have a view tree observer like this:
rowsContainerVto = rowsContainerView.ViewTreeObserver;
rowsContainerVto.GlobalLayout += RowsContainerVto_GlobalLayout;
void RowsContainerVto_GlobalLayout (object sender, EventArgs e)
{
…

Amir J
- 123
- 8
1
vote
0 answers
How to use ViewTreeObserver on map marker object?
I have a custom map marker that I would like to scale based on the text of the marker. I want to retrieve the width of this marker. The issue I am facing is that when the app is first launched, the width value is 0. I am getting the width too early.…

portfoliobuilder
- 7,556
- 14
- 76
- 136
1
vote
1 answer
ViewTreeObserver Giving Null Pointer Exception for getMeasuredHeight() Method
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewTreeObserver android.view.View.getViewTreeObserver()' on a null object reference

Akshay
- 21
- 1
- 5
1
vote
0 answers
Handling a Runnable thread during configuration changes
With the following codes, I was wondering how to handle a Runnable object (for a timer) and a ViewTreeObserver (for handling configuration changes between portrait and landscape) together in one activity, because my View (linearLayout) doesn't get…

DaveNOTDavid
- 1,753
- 5
- 19
- 37
0
votes
1 answer
Android -How to Remove ViewTreeObserver GlobalLayoutListener with .removeOnGlobalFocusChangeListener
How do I remove a viewTreeObserver? There are 3 different removeOnGlobalFocusChangeListener callbacks
class MyFragment: Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view,…

Lance Samaria
- 17,576
- 18
- 108
- 256
0
votes
1 answer
ViewTreeObserver NullPointerException Crash in Android
I am getting below viewTreeObserver crash on firebase. What could be the possible cause? ViewTreeObserver is used at multiple places in the app so unsure where exactly this crash is happening
Fatal Exception: java.lang.NullPointerException: Attempt…

Ankush Kapoor
- 445
- 1
- 8
- 20
0
votes
1 answer
Android: performClick() on a Button inside a ViewFlipper?
I have an Activity method "finishCardUpdateAndClose()" that is called after a Fragment onDismiss(). In the method I am trying to simulate a click on a button on the Activity UI. The button is an element of a ViewFlipper. I try to set up a View…

AJW
- 1,578
- 3
- 36
- 77
0
votes
1 answer
Get Height Of View After Content Is Populated At Runtime
I have a Cardview with height WRAP_CONTENT . Content of Cardview is to be populated after network call . And based on the height of Cardview I have to set background in my fragment . So I tried using ViewTreeObserver and Post method but I am still…

Kamal Kumar Majhi
- 51
- 1
- 12
0
votes
0 answers
RecyclerView is not using appropriate element from ViewTreeObserver?
I am creating contact app. When creating new Contact, user can turn on camera and take a photo. There is a ContactsActivity which displays all Contacts using RecyclerView. Inside RecyclerView (ContactsAdapter), I am recalculating size of taken image…

Wrapper
- 794
- 10
- 25
0
votes
3 answers
Using ViewTreeObserver i am adding setMaxLines and setEllipsize in MaterialTextView inside RecyclerView.Adapter
I am set MaterialTextView inside RelativeLayout and set RelativeLayout size programmatically different size for every device.
Then i have using ViewTreeObserver to set setMaxLines and setEllipsize in MaterialTextView but i am facing some problem…

Kishan Viramgama
- 893
- 1
- 11
- 23
0
votes
1 answer
Android kotlin Check if any view slides out of screen when any view changes size
All views in my constraint Layout have layout_height as wrap_content. My first view is bottom to bottom constrained to constraint layout. the next is bottom to top constrained to previous one and so on. My constraint Layout has layout_height as…

fisio
- 494
- 6
- 12
0
votes
1 answer
Create a PDF after linear layout is done drawing
I am trying to create a PDF of a nested linear layout with a table layout. My problem is that my initial attempts led to a file being drawn without the complete view.
To get around this I decided to only write to the file after the view is done…

ItIsEntropy
- 306
- 3
- 13
0
votes
0 answers
Screen rotation, makes a view to be 0 sized
I have a AppCompatDialogFragment with this code:
View anchorView = getActivity().findViewById("R.id.myView")
if (ViewCompat.isLaidOut(anchorView)) {
anchorView.getLocationInWindow(location);
Log.w(
"*****",
…

Elad Benda
- 35,076
- 87
- 265
- 471
0
votes
0 answers
getLineCount returns the number of characters after orientation not the lines number
I am trying to make an expandable textview, it is working correctly,
but the problem is after rotation the textview.getLinesCount() returns the number of charcters in the textview not the number of lines, so it doesn't work correctly after the…

Basma El-mihy
- 21
- 4