0

Getting height of LinearLayout return -1.

Code :

LinearLayout layout = (LinearLayout)findViewById(R.id.create_trip_layout);
android.view.ViewGroup.LayoutParams param = layout.getLayoutParams();
Log.d("Layout height : ", param.height + "");
4

1 回答 1

1

Use layout.getHeight(); it returns its height.

From the doc

returns:
    The height of your view, in pixels. 

to work you have to wait until Android has drawn the root of your Layout.

于 2013-08-02T10:19:16.703 回答