Set view height and width

Eungi KimΒ·2020λ…„ 11μ›” 10일
0
view.getLayoutParams().height = 20; //px
// If you're setting the height after the layout has already been 'laid out', 
// make sure you also call:
view.requestLayout();
// getLayout() will fail with null-exception
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100); // px
view.setLayoutParams(layoutParams);
int dimensionInDp = (int) TypedValue.applyDimension(
		TypedValue.COMPLEX_UNIT_DIP, 
        	dimensionInPixel, 
        	getResources().getDisplayMetrics());

https://stackoverflow.com/questions/3144940/set-imageview-width-and-height-programmatically

profile
Run and gun and debugun

0개의 λŒ“κΈ€