Answers for "programatically set height and width of weview in android"

1

set height of layout programmatically android

// Gets linearlayout
LinearLayout layout = findViewById(R.id.numberPadLayout);
// Gets the layout params that will allow you to resize the layout
LayoutParams params = layout.getLayoutParams();
// Changes the height and width to the specified *pixels*
params.height = 100;
params.width = 100;
layout.setLayoutParams(params);
Posted by: Guest on December-28-2020
1

how to set view width programmatically in android

View view = findViewById(R.id.nutrition_bar_filled);
LayoutParams layoutParams = view.getLayoutParams();
layoutParams.width = newWidth;
view.setLayoutParams(layoutParams);
Posted by: Guest on April-19-2020

Code answers related to "programatically set height and width of weview in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language