如果布局的宽度和高度大于屏幕,我们如何获得布局的宽度和高度(例如LinearLayout
)?
我只能使用getWidth()
和getHeight()
获得与屏幕一样大的尺寸。
这甚至可能吗?
答案 0 :(得分:0)
试试这个 -
View view = getLayoutInflater().inflate(R.layout.your_activity, null);
LinearLayout linearlayout = (LinearLayout)view.findViewById(R.id.yourlinearlayout);
linearlayout.measure(0,0);
int width = linearlayout.getMeasuredWidth();
int height = linearlayout.getMeasuredHeight();