Android 填充布局中的空白区域

标签 android xml

我的布局:

<?xml version="1.0" encoding="utf-8"?>

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

    <LinearLayout 
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:background="@color/skyblue" >

        <TextView
          android:id="@+id/tvPlaceHeader"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/places"
          android:layout_margin="10dp"
          android:layout_gravity="center"
          android:textAppearance="?android:attr/textAppearanceLarge" />

      <ImageView
         android:contentDescription="@string/search"
         android:id="@+id/ivPlace"
         android:layout_gravity="center"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/logo" />

     <TextView
         android:contentDescription="@string/search"
         android:id="@+id/tvTrivia"
         android:textSize="14sp"
         android:textStyle="bold"
         android:layout_margin="10dp"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/search" />

    </LinearLayout>
</ScrollView>

截图:

enter image description here

我的问题是,为什么它没有覆盖整个布局?我的意思是它下面有一个空白,但我在我的 xml 中声明它的背景颜色为蓝色。

最佳答案

更改内部 LinearLayout 高度

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="fill_parent" // CHANGED LINE
    android:orientation="vertical"
    android:background="@color/skyblue" >

关于Android 填充布局中的空白区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15270704/

相关文章:

java - Liquibase liquibase.exception.ValidationFailedException : Validation Failed:

java - 有没有办法在 Spring XML 中指定默认属性值?

android - 在 Android 中滑动页面

android - 单击更改 ListView 项目的图像

java - JAXB 和同一元素中的多种内容类型

java - 如何通过请求体获取xml并解析到Spring boot

c# - configSection 与纯 xml 的优点/缺点?

android - 可以使用不同的 viapoints 设置替代路线吗?

android - 为什么 Android 通知的 LED 设置不起作用

java - java中的JSON对象读取