Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓:如何对齐两张图片,一张在中间,一张在底部_Android - Fatal编程技术网

Android 安卓:如何对齐两张图片,一张在中间,一张在底部

Android 安卓:如何对齐两张图片,一张在中间,一张在底部,android,Android,如何使用LinearLayout对齐两个图像,一个在中间,一个在底部 因为我发现RelativeLayout标记为legacy 这里有一个问题,但用于启动屏幕 如何使用 线性布局 对于线性布局,可以将设置为垂直 要使图像居中,请使用android:layout\u gravity=“center\u horizontal” 代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:

如何使用LinearLayout对齐两个图像,一个在中间,一个在底部
因为我发现RelativeLayout标记为legacy

这里有一个问题,但用于启动屏幕

如何使用 线性布局

对于
线性布局
,可以将设置为垂直

要使图像居中,请使用android:layout\u gravity=“center\u horizontal”

代码

   <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

    <ImageView
            android:layout_marginTop="90dp"
            android:layout_gravity="center_horizontal"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:background="@drawable/image"/>

    <ImageView
            android:layout_marginTop="30dp"
            android:layout_gravity="center_horizontal"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:background="@drawable/image2"/>
</LinearLayout>

输出




玩marginBottom和marginTop属性

这个问题有更新吗?
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:adjustViewBounds="true"
        android:layout_weight="1"
        android:src="@drawable/image_1"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="100dp"
        android:src="@drawable/image_2"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="89dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="100dp"
        android:layout_marginTop="190dp"
        android:layout_weight="1"
        app:srcCompat="@drawable/child_big" />
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="100dp"
        app:srcCompat="@android:drawable/btn_star" />



</LinearLayout>