Questions tagged [android-measure]

13 questions
21
votes
3 answers

ConstraintLayout onMeasure very slow

so I tried refactoring some of my recycler ViewHolders to ConstraintLayouts. After I did it I was shocked after what I saw. Inflating a single view takes 20x more time than usual LinearLayout. It actually skips so many frames while doing it. EDIT:…
9
votes
1 answer

Changing LayoutParams on an Android view has no effect, even after calling requestLayout

I've run into this situation two or three times, where I have some code that looks like this: ViewGroup.LayoutParams params = myView.getLayoutParams(); params.height = 240; myView.requestLayout(); Or alternatively: ViewGroup.LayoutParams…
fpsulli3
  • 363
  • 1
  • 11
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…
2
votes
0 answers

Android folding cell library is not getting width correctly when scrolling a cell in recycler view

I have a recyclerView made up of Folding cells. (library can be found here: https://github.com/Ramotion/folding-cell-android each element in the recyclerView can be clicked on and it will unfold like a paper. onBindViewHolder has a condition to…
bcsta
  • 1,963
  • 3
  • 22
  • 61
2
votes
0 answers

Efficient WebView resizing

I've implemented floating Toolbar in my app (hides with scroll down, shows on up) and now I see some flickering views inside WebView, to be precise these sticked to the bottom. I've noticed that this happens when I'm resizing WebView due to Toolbar…
1
vote
0 answers

How to get the correct available size on Window (without all the decor elements)?

Is there any way to get the available size on a window without decor elements (status bar, navigation bar and cut outs)? I've tried using the getSize from WindowManager.getDisplay(), but for some reason, if the device does not have a display cut…
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61
1
vote
1 answer

Android View's .onMeasure side effect

I'm having an issue where .measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) somehow alters the view's state. I've set up a view which listens to the onClick event and performs the .measure. Note that when I perform…
Erik Lilja
  • 23
  • 5
1
vote
4 answers

TextView with different text lengths aligning next to horizontally

I'm looking for efficient way (best XML only) to align two TextViews horizontally, smth like this:
snachmsm
  • 17,866
  • 3
  • 32
  • 74
0
votes
0 answers

How to retain button width on content change in jetpack compose

I am trying to implement a generic button component that has a loading state. I came up with following approach that works great: @Preview @Composable private fun CustomButtonPreview() { var isLoading by remember { mutableStateOf(false) } …
0
votes
1 answer

How can I convert ViewGroup into white background Bitmap?

view.measure(MeasureSpec.makeMeasureSpec(view.layoutParams.width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(view.layoutParams.height, MeasureSpec.EXACTLY)) view.layout(0, 0, view.measuredWidth,…
0
votes
2 answers

Spinner dropdown items: how is width determined?

I have a Spinner in my app, with customized dropdown views. This is what the layout of the dropdown items look like:
0
votes
1 answer

How to set width to textview in one child exactly the same as the textview in another child?

I make some custom view, and now im stuck with one specific issue. Now ill try to explain: in my case the view hierarchy is
0
votes
0 answers

how to get width of view when initializing without any listeners?

I need to get width of view that is smaller that default window width. I tried getViewTreeObserver, but it is only executed at the end of all draws that is why variable needed is 0; I tried to call my fragment(which will use the width) in the…