布局的图像背景不是 acroos screen,而是只有一半?
我有一个布局,带有图像、按钮和文本视图。当我将图像设置为背景时,该背景图像只有屏幕的一半,其余部分是黑色的。这种方法在我有一堆东西的其他布局上很好,但这里它只在屏幕的一半上。我怎样才能做到这一点?
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:src="@drawable/bonbon"
android:id="@+id/imageView1"
android:layout_height="wrap_content"/>
<cro.perger.bonbon.MyTextView
android:id="@+id/textView1"
android:text="Stanje aktiviranih paketa"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<Button android:layout_height="wrap_content"
android:text="Provjeri stanje"
android:id="@+id/provjeriStanje"
android:layout_width="fill_parent"/>
<TextView android:text=" "
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
I have a layout, with a image, button and a textview. When I set image as backgroung, this background image is only Half of screen, and the rest is black. This method is good on other layout where i have bunch of stuff, but here it is only on half of the screen. How can i make this right ??
My layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:src="@drawable/bonbon"
android:id="@+id/imageView1"
android:layout_height="wrap_content"/>
<cro.perger.bonbon.MyTextView
android:id="@+id/textView1"
android:text="Stanje aktiviranih paketa"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<Button android:layout_height="wrap_content"
android:text="Provjeri stanje"
android:id="@+id/provjeriStanje"
android:layout_width="fill_parent"/>
<TextView android:text=" "
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您有一个 ScrollView 作为根组件,它的高度定义为“wrap_content”。这很可能是导致您的问题的原因。试试这个版本:
You have a ScrollView as a root component, it has it's height defined as "wrap_content". This is, most likely, the cause of your issue. Try this version:
您的滚动视图正在包装可能没有填满整个屏幕的内容。
将滚动视图标签中的 android:layout_height="wrap_content" 更改为 fill_parent 。
Your scrollview is wrapping the content which probably isn't filling the whole screen.
Change android:layout_height="wrap_content" to fill_parent in the scrollview tag.
现在试试这个...
Now Try this...