我有一个非常愚蠢的问题。

我无法在横向活动中心设置ImageView。

我仅在活动的左中心和上中心有一个图像。

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:background="@drawable/load_bg"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="horizontal">

    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/running_animation"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center_vertical" />

</LinearLayout>

最佳答案

Yuu缺少LinearLayout的android:gravity="center"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/load_bg"
    android:gravity="center"
    android:orientation="horizontal" >

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/running_animation"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_vertical" />

</LinearLayout>

07-28 03:38
查看更多