Tôi có LinearLayout có chế độ hiển thị được đặt thành "Đã qua" theo mặc định, Tôi cần có chiều cao của chế độ xem này để thực hiện hoạt ảnh trượt khi nó hiển thị. Làm thế nào để tôi có được tổng chiều cao của trạng thái hiển thị, vì View.getHeight trả về số không khi bố cục không được gọi.getHeight cho Chế độ xem có khả năng hiển thị = đi
<LinearLayout
android:id="@+id/card_checkin_layout_termsconditionsconfirmation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:gravity="center_horizontal"
android:background="#d0d0d0"
android:visibility="invisible"
android:orientation="vertical" >
<Button
android:id="@+id/card_checkin_button_confirmdetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/shape_checkin_buttons2"
android:text="> Confirm your details"
android:paddingLeft="8dp"
android:gravity="left|center_vertical"
android:textColor="@color/card_checkin_button_textcolor_blue"
/>
<Button
android:id="@+id/card_checkin_button_termsandconditions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:paddingLeft="8dp"
android:background="@drawable/shape_checkin_buttons2"
android:text="> Terms and Conditions"
android:gravity="left|center_vertical"
android:textColor="@color/card_checkin_button_textcolor_blue"
/>
</LinearLayout>
Set nó cho 'View.VISIBLE' ban đầu. Sử dụng 'GlobalLayoutListener' để nhận một cuộc gọi lại khi bố cục được xây dựng, lấy chiều cao, sau đó đặt nó thành' View.GONE' và bố cục yêu cầu. – Simon