例如,这是mButton
:
<Button
android:id="@+id/mbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="mButton" />
这就是我试图获得高度的方式:
int height = mButton.getLayoutParams.height;
但是当我记录它时,它说高度是-2。我认为这可能是“wrap_content”的 int 值。那么我怎样才能得到实际的高度呢?谢谢!