I've different layout. Some created by xml. Some others dynamically via code. When I am on xml I can set width or height with "wrap_content" value. How to get the same result dynamically? This is the snippet of my dynamic TextView. I need to remove "final int width = 440;" and get same value of "wrap_content". How?
final int width = 440;
final int height = textViewHeight;
final int top = getNewTop(height);
FrameLayout.LayoutParams layoutParams;
layoutParams = getLayoutParams(width, height, top);
TextView textView;
textView = new TextView(_registerNewMealActivity);
textView.setText(text);
textView.setLayoutParams(layoutParams);
_frameLayout.addView(textView);
You can use :
textView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 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