简体   繁体   English

用背景图像填充整个屏幕!

[英]filling whole screen with background image!

hii! 嗨! i am trying to fill an image onto my screen, but it is just covering around 75-80% part of whole screen, not whole screen .the codeblock i am using is as: 我正在尝试将图像填充到我的屏幕上,但是它仅覆盖整个屏幕的大约75-80%的部分,而不是整个屏幕。我使用的代码块如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FILL_PARENT,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);

and main.xml code snippt: 和main.xml代码片段:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/homepage_image"
android:gravity="center"
><ImageButton
android:id="@+id/btnSequence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_sequence"
android:gravity="center_vertical"/>
<ImageButton
android:id="@+id/btnVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_video"
android:gravity="center_vertical"
/>
<ImageButton
android:id="@+id/btnInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_info"
android:gravity="center_vertical"
/>
</LinearLayout>

thanks 谢谢

On my xml I do this to fill the hole screen with an image view: 在我的xml中,我这样做是用图像视图填充孔屏幕:

<ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            **android:scaleType="fitXY"**
            android:src="@drawable/*drawablename*" />

Of course be careful about the size and resolution of you image. 当然,请注意图像的大小和分辨率。

If image is less than device screen size android will default to that android:gravity="center" command that you gave it..is the image centered on screen? 如果图像小于设备屏幕尺寸,则android将默认使用您给它的android:gravity =“ center”命令。图像是否在屏幕上居中? If so than that might be what is occurring..in which case you need to edit image to screen size of the device. 如果是这样,那可能正在发生..在这种情况下,您需要将图像编辑为设备的屏幕尺寸。

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

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