繁体   English   中英

Android背景没有填充屏幕

[英]Android background not filling screen

我有一个带有tabHost的应用程序; 在其中一个标签上我有一个背景图像,但图像没有填满整个屏幕:

bgnd图像

我的图片是480 x 800像素

我的home.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/home_bgnd">
</LinearLayout>

如何修复此代码,以便我的图像覆盖整个屏幕?

在XML中使用ImageView并设置android:scaleType="fitXY"以使其延伸到其父布局。 作为父布局,我建议你使用FrameLayout这样图像就可以作为它的背景。

例如:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/your_source"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <!-- your other views here -->

    </LinearLayout>
</FrameLayout>

在这种情况下,您似乎正在使用tabhost,您必须查看具有tabhost的xml布局。

检查包含android:id="@android:id/tabcontent"视图中的填充,并从那里删除该填充或边距。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM