【问题标题】:Why the height of the scroll view is longer than the actual content为什么滚动视图的高度比实际内容长
【发布时间】:2014-02-06 14:55:44
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:scaleType="fitStart"
            android:src="@drawable/splash_bg" />

        <ImageView
            android:id="@+id/photo_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_margin="20dp"
            android:adjustViewBounds="true" />

        <TextView
            android:id="@+id/share_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/photo_area"
            android:layout_marginLeft="20dp"
            android:text="@string/share_title"
            android:textColor="@android:color/white" />

        <EditText
            android:id="@+id/share_content"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_below="@+id/share_title"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="@drawable/custom_textarea"
            android:gravity="top|left"
            android:hint="default message" />

        <ImageView
            android:id="@+id/share_submit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/share_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:src="@drawable/photo_taken_btn_submit" />
    </RelativeLayout>

</ScrollView>

这是布局的xml。 photo_area 默认没有图像设置,但它会从互联网上下载一张图片并在上面设置。问题是内容视图的高度比它应该的要长,所以最后有很多空白空间。我尝试在线性布局中删除背景,高度降低了一点,但仍然有一些空白空间如何解决?谢谢

【问题讨论】:

    标签: android android-layout height android-scrollview


    【解决方案1】:

    在 imageview xml 中使用 android:adjustviewbound = "true" 修复问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-16
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 2022-06-11
      • 2018-01-11
      • 1970-01-01
      • 2020-07-16
      相关资源
      最近更新 更多