0

I am using the following layout:

enter image description here

FrameLayout fills the entire Viewport, i.e. width and height are set to MATCH_PARENT

Width and height of RelativeLayout are set to WRAP_CONTENT

View1 to View5 have fixed dimensions e.g. width = 500, height = 50

View 5 lies near the border of FrameLayout and is squeezed by Android, so that it lies fully within FrameLayout. The height of View5 should be 50 but unfortunately Android changes it to a smaller value.

How can I avoid, that Android changes the height of View5 ?

When I scroll RelativeLayout, the error is still existing.

A similar behavior is described here: button is squeezed when it exceeds layout

4

1 回答 1

0

解决此问题的“更好”方法是使用ScrollView类似

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >
         <View
             android:id="@+id/view1"
             android:layout_width="match_parent"
             android:layout_height="50dp"
             android:layout_alignParentTop="true" />
         <View
             android:id="@+id/view2"
             android:layout_width="match_parent"
             android:layout_height="50dp"
             android:layout_below="@+id/view1" />
         <View
             android:id="@+id/view3"
             android:layout_width="match_parent"
             android:layout_height="50dp"
             android:layout_below="@+id/view2" />
 <!-- YOU GET THE IDEA -->

    </RelativeLayout> 
</ScrollView>
于 2017-02-14T22:30:33.383 回答