I'm have a custom View
containing 8 TextView
s that I am using as a row in a table. I need to set the minimum height of these children once the data has been inserted as I would like the height of all 8 TextView
s to expand to the height of the tallest one.
I am currently doing this in code as follows:
for(int i = 0; i < m_textViews.length; i++)
{
m_textViews[i].setMinHeight(heightPx);
m_textViews[i].setHeight(heightPx);
}
I am trying to improve the code performance, leading me to wonder actually what the difference was between setMinHeight()
and setMinimumHeight()
?
Thanks in advance
I recommend using setMinHeight because it is written for TextViews specifically and it updates the mMinMode to hold PIXELS value
Here is SetMinHeight from the TextView.java sourceCode
/**
* Makes the TextView at least this many pixels tall.
*
* Setting this value overrides any other (minimum) number of lines setting.
*
* @attr ref android.R.styleable#TextView_minHeight
*/
@android.view.RemotableViewMethod
public void setMinHeight(int minHeight) {
mMinimum = minHeight;
mMinMode = PIXELS;
requestLayout();
invalidate();
}
and Here is SetMinimumHeight from the View.java SourceCode
/**
* Sets the minimum height of the view. It is not guaranteed the view will
* be able to achieve this minimum height (for example, if its parent layout
* constrains it with less available height).
*
* @param minHeight The minimum height the view will try to be.
*
* @see #getMinimumHeight()
*
* @attr ref android.R.styleable#View_minHeight
*/
public void setMinimumHeight(int minHeight) {
mMinHeight = minHeight
requestLayout();
}
TextView.java:
http://androidxref.com/5.1.0_r1/xref/frameworks/base/core/java/android/widget/TextView.java
View.java:
http://androidxref.com/5.1.0_r1/xref/frameworks/base/core/java/android/view/View.java
setMinHeight(int minHeight)
Makes the TextView at least this many pixels tall. Setting this value overrides any other (minimum) number of lines setting.
setMinimumHeight(int minHeight)
Sets the minimum height of the view. It is not guaranteed the view will be able to achieve this minimum height (for example, if its parent layout constrains it with less available height).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With