Android/Tip&Tech
[팁]원하는 view 사이즈 알아내기
행복한 수지아빠
2012. 9. 28. 15:21
반응형
public int measureCellWidth( Context context, View cell )
{
// We need a fake parent
FrameLayout buffer = new FrameLayout( context );
android.widget.AbsListView.LayoutParams layoutParams = new android.widget.AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
buffer.addView( cell, layoutParams);
cell.forceLayout();
cell.measure(1000, 1000);
int width = cell.getMeasuredWidth();
buffer.removeAllViews();
return width;
}
반응형