Android layout 动态更新布局

Android layout 动态更新布局,android-layout,android-camera,android-image,Android Layout,Android Camera,Android Image,我正在设计一个布局,其中我在屏幕中央有3个按钮,在屏幕底部有一个网格视图。在网格视图中,我正在添加图像。但当我添加图像时,按钮固定在它们的位置,在许多图像之后,gridview开始从底部覆盖按钮。当图像数量增加时,是否有任何方法可以动态调整屏幕 my activity.xml文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.and

我正在设计一个布局,其中我在屏幕中央有3个按钮,在屏幕底部有一个网格视图。在网格视图中,我正在添加图像。但当我添加图像时,按钮固定在它们的位置,在许多图像之后,gridview开始从底部覆盖按钮。当图像数量增加时,是否有任何方法可以动态调整屏幕

my activity.xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:andriod="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >


    <Button
        android:id="@+id/address1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="locate yourself"
        android:onClick="address"/>

    <Button
        android:id="@+id/image1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="photo"
        android:onClick="takePicture"/>

    <Button
        android:id="@+id/confirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="place order"
        android:onClick="confirm"/>


</LinearLayout>

<GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_margin="8dp"
    android:columnWidth="90dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:gravity="center">



将您的相对位置设置为线性布局。试一试并告诉我们结果。那么如何将按钮定位在屏幕的中心?使用重力参数进行定位。为每个按钮添加重力参数,例如左、右、中。试试看。
</RelativeLayout>