5
Tôi đang cố gắng để tạo ra một FrameLayout
lập trình như sau (điểm này sẽ nổi trên trung tâm đáy của một LinearLayout
):FrameLayout layout_weight lập trình
FrameLayout bottomFrameLayout = new FrameLayout(context);
bottomFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(0,LayoutParams.FILL_PARENT,Gravity.CENTER | Gravity.BOTTOM));
Kể từ khi tôi đặt layout_width=0dp
, tôi muốn cũng phải thiết lập layout_weight
để kiểm soát chiều rộng. Làm thế nào tôi có thể làm điều đó?
nếu tôi sử dụng LinearLayout.LayoutParams để thiết lập cân làm thế nào để thiết lập mức độ nghiêm trọng? – prostock
Thử gán giá trị cho trường 'gravity', như' layoutParamsObject.gravity = Gravity.SOME_OF_THE_CONSTANTS' –
@NikolaDespotoski FrameLayout không phải là con của LinearLayout theo tham chiếu, xem http://developer.android.com/reference/android/ widget/FrameLayout.html và FrameLayout.LayoutParams không phải là con của LinearLayout.LayoutParams xem http://developer.android.com/reference/android/widget/FrameLayout.LayoutParams.html. Câu trả lời của bạn đã lỗi thời chưa? – soriak