1

我想将我的图像视图放在中心上方一点。我使用 centerHorizo​​ntal="true" 和 paddingBottom ,但它被放置在绝对中心。“填充”没有做这项工作。我应该怎么办?

<ImageView
    android:id="@+id/imageview"
    style="@style/myImageView"
    android:layout_width="200dp"
    android:layout_height="100dp"
    android:layout_centerHorizontal="true"
    android:paddingBottom="300dp"
    android:src="@drawable/ic_launcher" />
4

3 回答 3

1

尝试使用 layout:margin_bottom 。如果没有得到你想要的。应用 relativelayout 和相同的 bottom_margin。

于 2013-02-02T08:30:25.117 回答
1

找不到确切的答案,但有另一种方法。我在相对布局内创建了一个框架布局,将图像视图放置在其中,然后将重力设置为中心。如果有更好的解决方案请留言。我的代码:

Inside the relative layout--
 <FrameLayout
    android:layout_width="800dp"
    android:layout_height="400dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" 
    android:layout_marginRight="30dp"
    android:layout_marginBottom="100dp"

    >
    <ImageView
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:src="@drawable/ic_launcher"
    style="@style/myImageView" />
</FrameLayout>
于 2013-02-02T14:32:37.387 回答
0

我希望您使用的是相对布局,而不是线性或绝对布局。

于 2013-02-02T07:34:01.050 回答