UI的一些奇怪的行为?

时间:2011-07-26 10:17:19

标签: android user-interface alignment

这是我的静态xml:

<LinearLayout
    android:id="@+id/LinearLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <RelativeLayout
        android:id="@+id/Header"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1.5"
        android:background="@drawable/header_bg"
        android:padding="0dp"
        >

        <ImageView
            android:id="@+id/hLogo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/logo"
            />

        <TextView
            android:id="@+id/hActiveCategory"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Today"
            android:textSize="18sp"
            android:textColor="#FFFFFF"
            />

        <Button
            android:id="@+id/hRefreshButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:drawableRight="@drawable/refresh"
            android:layout_alignParentRight="true"
            android:padding="0dp"
            />

    </RelativeLayout>

</LinearLayout>

发生了什么事? - 当我尝试将 按钮 id = hRefreshButton 对齐到其父级的右侧时( RelativeLayout id = Header )按钮与屏幕右边界之间仍有空格。为什么会这样?有什么建议?此外,我必须强调,我正在测试AVD模拟器。

1 个答案:

答案 0 :(得分:1)

您的按钮相对于父级(相对布局)正确对齐,但由于默认背景,您可能会在按钮右侧看到一些空格。

尝试将背景设置为某些图像或设置背景颜色,您将亲自查看。

词shash

相关问题