How to make background larger then screen and rotate it? - android

Want to make space background to my activity and begin to rotate it slowly, but i stuck with that:
screenshot (http://postimg.org/)
The effect I need need I can get if add in XML file
android:scaleY="2"
android:scaleX="2"
but it will not work, android scale pic down when app start.
Guys, really need your help, I in android for 4 day and have bad english
----ADDED---
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/backgroundd"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
</RelativeLayout>

I have not tried this, and I am not sure it is the best solution, but could you set a negative android:layout_marginon the image?
android:layout_margin="-100dp"
See here for more: How to get a view larger than its parent?
Also, posting your full XML could help us know more about how you are setting up the layout.

Related

Using PhilJay / MPAndroidChart, How do I take a screenshot of the entire chart and not just what's visible?

How do I get a bitmap of the entire chart and not just what's visible? I tried the chart.getChartBitmap(); and chart.saveToGallery("filename"); Whilst both of them work, they only capture what's visible to the user. I wish to capture the entire chart regardless of its visibility to the user. Please help. Thank you very much.
I don't know if this answer will be bashed. But it worked for me. I just figured it out.
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="horizontal">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" >
<com.github.mikephil.charting.charts.CombinedChart
android:id="#+id/combinedChartBroodingGrowing"
android:layout_width="3000dp"
android:layout_height="1000dp"
/>
</LinearLayout>
</HorizontalScrollView>
Unfortunately you'll need to specify the layout_width and layout_height explicitly in order for this to work(You'll need to play around and decide what's best for you. Also, please note: I haven't checked for any side effects. Use with discretion. I'm so sorry!). Also make sure setVisibleXRangeMaximum() is not set. And then call saveToGallery() as usual. You'll see the entire chart saved to gallery. :)

Kindle Fire Images not stretching to fill screen

Long time lurker, first time poster here!
I'm having a problem specifically on my Kindle Fire where when I insert an image (in this case a header and footer) into a relative layout and set the width to "match_parent" or "fill_parent", there is a white border around the sides.
However when I put an image into a linear layout and set the exact same parameters, it works properly.
It works perfectly on phones and my Samsung tablet, I just can't figure out what's going wrong on the Fire.
I'm hoping someone here has a fix for this problem. I can't find anything about it through google or the StackOverflow search.
Here is the XML code for my header and the relative layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="*****************.MainActivity"
android:background="#drawable/background_xhdpi">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageHeader"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/header_xhdpi"
android:adjustViewBounds="true"/>
(Example of the problem)
Thanks for your time!
To anyone else having this problem a fellow developer gave me the solution.
Add this to your ImageViews that aren't stretching properly:
android:adjustViewBounds="true"
android:scaleType="fitXY"

How do I get a background image to scale in android studio?

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.

layer application in android

I am a new one in Android so please sorry for stupidity.
Well my problem is in multiple layers -
I would like to combine two transparent ImageViews one above the other. This is similar to photoshops layers, what is the sample layers activity in android?
You can use a RelativeLayout for this.
The property android:layout_centerInParent If true, centers the child horizontally and vertically within its parent. [boolean]
Similarly there are properties like ,
android:layout_alignParentLeft,
android:layout_alignParentRight,
android:layout_alignParentTop,
android:layout_alignParentBottom.
Try these.
Already answered Overlapping Views in Android ? That should be all you need, using RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/layout"
>
<ImageView android:id="#+id/imageview1"
android:background="#00000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/image1"
/>
<ImageView android:id="#+id/imageview2"
android:background="#00000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/image2"
/>
</RelativeLayout>
would be an example code for you.
you can use the layer-list, for a full investigation, please refer to http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
Well its quite possible to do in android, but the thing is what actually you are going to do with that. you can give the same positions for both the images in layout now both will be overlapped and based on your condition or situation you can show and hide one another programatically. In the same way you can give multiple images overlapped on one another. Hope this will help you out to understand :)

Moving image imageview

I have a question. I've done in XML ImageView. Unfortunately, the "holds" on the left side of the screen on the phone. I wish this picture could shift to the right place.
I would like to point to the X and Y position of the image shifted to the indicated place.
How do I do this?
Please explain in detail because I am a novice programmer of Java.
Sorry for the mistakes. I'm not saying every day in the English language.
I'd not recommend setting fixed positions for elements as it will make your life only harder for different screen sizes.
Use a RelativeLayout. Here is an example of how your XML could look like.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
android:layout_alignParentRight="true"/>
</RelativeLayout>
This way the ImageView will always be bound to its parents right side. This is achieved by setting android:layout_alignParentRight="true" on the ImageView.
Hope it helps.

Categories

Resources