开发者

Android getting layout to dynamically position and space elements within a layout

开发者 https://www.devze.com 2023-02-19 08:50 出处:网络
I have the following layout: begin RelativeLayout android:layout_height=\"fill_parent\" android:layout_width=\"fill_parent\"

I have the following layout:

begin RelativeLayout
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    TextView 
begin LinearLayout
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"

    4 - 6 radio buttons  variable number

end LinearLayout
  TextView
end RelativeLayout

So when there are six radio buttons it displays fine. When there are only 4 they move up to the top and I would like them centered. I did not find a android:layout_alignParentCenter="true" or middle option for the LinearLayout itself so it would goto the center to of the screen. Individually the radio button elements make up 4-6 elements variably. So how do I get these 4 elements positioned in the ce开发者_运维知识库nter of the linear layout or the linear layout centered within the screen. Thanks


Have you tried setting android:layout_centerVertical="true" on your LinearLayout?

You would probably need to set the LinearLayout to use android:layout_height="wrap_content" for this to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消