Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.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
Java 将图像居中放置在LinearLayout底部和我的应用程序底部之间_Java_Android_Xml_Layout - Fatal编程技术网

Java 将图像居中放置在LinearLayout底部和我的应用程序底部之间

Java 将图像居中放置在LinearLayout底部和我的应用程序底部之间,java,android,xml,layout,Java,Android,Xml,Layout,我试图将ImageView放在我的屏幕中央,介于LinearLayout底部和应用程序底部之间,我试图使用id,但没有成功 这是我搜索要执行的操作的图像: 所以我想把饼干放在1和2之间 这是我的代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:too

我试图将ImageView放在我的屏幕中央,介于LinearLayout底部和应用程序底部之间,我试图使用id,但没有成功

这是我搜索要执行的操作的图像:

所以我想把饼干放在1和2之间


这是我的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/cookie"
        android:layout_width="240dp"
        android:layout_height="240dp"
        android:src="@drawable/cookie2"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/layout"

        />

    <LinearLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="#6000"
        android:layout_gravity="center_horizontal"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <TextView
            android:id="@+id/click"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/cookie_msg"
            android:textColor="@color/whiteColor"
            android:fontFamily="@font/kavoon"
            android:textSize="24sp"
            android:gravity="center"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="@font/kavoon"
            android:gravity="center"
            android:text="@string/cps_msg"
            android:textColor="@color/whiteColor"
            android:textSize="15sp" />

    </LinearLayout>

这应该可以做到

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bg"
        tools:context=".MainActivity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/layout"
            android:gravity="center">

          <!--wrap image view inside this linear layout-->
          <ImageView
            android:id="@+id/cookie"
            android:layout_width="240dp"
            android:layout_height="240dp"
            android:src="@drawable/cookie2"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/layout"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="#6000"
            android:layout_gravity="center_horizontal"
            android:gravity="center_vertical"
            android:orientation="vertical">

            <TextView
                android:id="@+id/click"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/cookie_msg"
                android:textColor="@color/whiteColor"
                android:fontFamily="@font/kavoon"
                android:textSize="24sp"
                android:gravity="center"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@font/kavoon"
                android:gravity="center"
                android:text="@string/cps_msg"
                android:textColor="@color/whiteColor"
                android:textSize="15sp" />

        </LinearLayout>
</RelativeLayout>


尝试将
android:layout\u centerVertical=“true”
添加到
图像视图
?我已经尝试过了,但我的图像现在位于应用程序的顶部和底部之间,这不是我想要的,伙计