0

当视图不适合其容器时,我希望从顶部而不是从底部裁剪视图。这是我的布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height=“100dp”

    <View
        android:id="@+id/my_view"
        android:layout_width="match_parent"
        android:layout_height=“80dp">

</FrameLayout>

现在 my_view 的底部 20dp 被裁剪。我应该怎么做才能裁剪 my_view 的顶部 20dp 而不是底部?

4

1 回答 1

1

您可以像这样使用视图的布局重力来执行此操作

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="wrap_content"
         android:background="#FFFFFF"
         android:layout_height="100dp">

<View
    android:id="@+id/my_view"
    android:layout_width="match_parent"
    android:layout_gravity="bottom"
    android:background="#000000"
    android:layout_height="80dp"/>

于 2016-02-08T12:21:30.067 回答