I have a Splash Screen with a background Image on top of it. I have a Video View which plays the video. The background of the video and that of the rest of the screen must match, hence I extracted the background color from the video and added a background image of the same color in the XML file.
The problem is, the color of the image does not match with the video on all versions of Android.
On Sony Xperia SP with v4.3:
On Micromax A1 with v6.0.1:
How do I get consistent result across all (or most) versions of Android?
XML of Splash Screen:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/logoback"
>
<VideoView android:id="#+id/myvideo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Instead of using drawable for setting the background, extract the colour code and set the colour code to background. It might resolve the issue.
Related
Good Day.Lately i have noticed an horrible delay between activity load which has an image attached to it's background.
Basically here is my simple layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_vip"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ink.va.activities.VIPActivity">
<ImageView
android:id="#+id/rootImageView"
android:src="#drawable/vip_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</RelativeLayout>
Meanwhile the issue is that i am very much confused the fact that activity takes a long way to load,if i remove the image,activity goes good,otherwise it takes a while to load,and i have tried to do the same with a PNG file of same image within different dimensions,scaled down with size of image and pixels so it shall be light,meanwhile my device still loads long the activity.The device is Huawei p8 Lite and i reckon it is not issue of device,anyone has any best practice for such situation?Thank you very much.
So I am trying to import a custom image as the background of an android app however it does not fill in all of the edges. The option I have seen is to set a second layout to be a frame layout and then place an image view within it with additional coding along the lines of android:scaleType="centerCrop". This will not fill the entire screen up for me however, heres a screenshot of what ends up happening -
Heres the xml code being used:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/backgroundImage"
android:background="#drawable/backgroundImgr"
android:scaleType="centerCrop"
/>
</FrameLayout>
Another issue is that different users use different resolutions so the background image has to be able to accommodate them all without being cut off. I'm not sure how to do this.
Set ScaleType fitXY and add android:adjustViewBounds ="true"
Please use android:src="#drawable/ instead background .I hope it will helps you.
I'm trying to use the ImageView in Xamarin plug-in for Visual Studio 2012, but when I use png with transparent background like a src I get just black screen.
That's strange but some time ago I could do it, but now I can't. Photo viewer in Visual Studio shows my image just black.
When I run my app on the device I get black screen too.
Here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Previously, I did not have this problem, I think...
If I use the same image in ImageButton and when I use image without transparent background all ok!
Renaming folders Drawable does not help.
How can I resolve this issue?
this is what i think, your image has a transparent background, already, and you also set the widgets background to transparent, now by default your activity or layout theme, by a wild guess has a background of black..so check this out.. Image has a transparent background and the image is a black image, and your widget has a transparent background which tends to show you the theme's background which is black, so your image fades in, to the background image showing the image but since the image itself opage portion is black you get a black Screen this is a wild guess, so do this.. set your linearLayout background to lets say red or white, and everything is gonna be alright
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:background="#fc9" // red or you could do it #fff white
android:minHeight="25px">
<ImageView
android:src="#drawable/plus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
Edit: i misread your question, my error was i tot you also specify transparency for the widget so, i admit my error, but my logic still stays, this time being the fact that, your layout theme is black and every widget follows that because you do not specify it, and your image is black, it still shows black ..
Note this is wild guess..ayt so try it.. and let me know
Ok I have created a background image in Inkscape. Exported that image and it looks correct, when I open it from Eclipse. However, when I build the project and apply that background to the Layout, it shows the complete opposite in the designer and on the device.
Here is what the image is supposed to look like. Correct background
Here is what the image looks like in the Eclipse Designer.Incorrect background.
Here is my Xml on a brand new Xml file.
<?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:background="#drawable/list_view_bg"
android:orientation="vertical" >
</LinearLayout>
I am utterly confused on this one. Any help is greatly appreciated.
You are most likely using a theme where the background in dark. As your background gradient is transparent the black background is showing through.
Switch to a light theme.
I want to make android home page background. I have imported a video file hp.mkv into the drawable folder. And call the file in main.xml. Following is my code snippet:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/hp">
<Button android:id="#+id/next_button"
android:layout_width="200dp"
android:layout_height="200dp"
android:gravity="center"
android:layout_marginLeft="270dp"
android:layout_marginTop="180dp"
android:background="#drawable/button_background"/>
</RelativeLayout>
Again In main activity file called like this: setContentView(R.layout.main);
But while running the application I saw a black screen coming behind the button, where I was expecting the video file to come. Can any one suggest me how to get out from this problem. Or any idea of using video in app's background in android.
Video files are not supported as "drawables". In other words you can't put it as drawable resource and expect it to be played back.
If you need video playback, you can use MediaPlayer. But that would require some extra code to be added to your activity.
A video file is NOT a drawable. You need to use a VideoView, to handle the displaying of the video.