Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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,我无法将图像垂直居中对齐。我缺少什么 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_marginTop="35dp" android:layout_height="fill_parent"> <Spinner android:la

我无法将图像垂直居中对齐。我缺少什么

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_marginTop="35dp"
    android:layout_height="fill_parent">
    <Spinner
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:id="@+id/moviesSpinner"
        android:prompt="@string/movie_prompt" />
    <ImageView
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:layout_alignParentRight="true"
        android:src="@drawable/Arrowcircled"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:id="@+id/imageView1" />
</RelativeLayout>

试试看

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_marginTop="35dp"
android:layout_height="fill_parent">
<Spinner
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:id="@+id/moviesSpinner"
    android:prompt="@string/movie_prompt" />
<ImageView
    android:src="@drawable/Arrowcircled"
    android:layout_width="20dp"
    android:layout_centerInParent="true"
    android:layout_below="@+id/moviesSpinner"
    android:layout_height="20dp"
    android:id="@+id/imageView1" />


如果您像这样添加大小为
微调器的父级
RelativeLayout
,则可以执行此操作

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="35dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Spinner
            android:id="@+id/moviesSpinner"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:prompt="@string/movie_prompt"/>

        <ImageView
            android:id="@+id/imageView1"

            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_gravity="center_vertical"
            android:src="@drawable/bemoir_splash3"/>
    </RelativeLayout>
</RelativeLayout>

删除此行android:layout\u alignParentRight=“true”并尝试此android:centerInParent=“true”