Image Scroll inside ImageView - java

So i have an image with dimensions of 6720x280, i want to put this image in the ImageView with dimensions of 280x280 and be able to scroll it on imageview touch (it is a product image, so basically i want to rotate the image inside the ImageView). So every time user drags ImageView image should rotate by 280px.
Here is a process of obtaining image:
Image is stored on the web server
User accesses product page
Script pre-loads the image from the server and saves it to assets folder
Using InputStream im opening image from assets folder
Converting it to Drawable
Updating ImageView with setImageDrawable
Since i'm new to android development, i don't know on how to approach this problem. So that's why i'm asking for help (at least, please, point me to the right direction), any help is really appreciated.
Thank you for your attention
P.S. Here is how it should look like:
This is how am i doing in HTML:
<div class="product_viewer" style="background-image: url('/assets/products/product_id.jpg'); background-position: -2800px 0px;"></div>

I am a newbie in android development too, but may be using a scrollview can help you. You can use addView method to add an imageview into a scrollview as i understood. Here is the developer guide for scrollview
https://developer.android.com/reference/android/widget/ScrollView.html
I hope it helps.

Related

android imageview come from over screen

hi.
I have a problem with android layout.
gif is what designer want I make. and I made things successfully but menu.
png(alpha image) is our menu image. last 40px of height is want to display.
and if user touch that 40px of image is coming down just like gif image shows.
I don't have any idea how can make that. Constraint Layout doesn't support negative value.
ps. png is based on 1080 height resolution. but I will add dynamic resolution calcaulator function, so don't mind about 40px. 40 just mean 'want to display part of imageview'
SOLVED.
make imageview in constraint layout xml and inflate it.
then you can set x,y location programmatically.
I confused it. because when I tried it, It doesn't work. you must know view has relative location.

How to change color in Drawable?

I have ImageView in my application, but images in this ImageView have white background. How I can delete this ColorDrawable. I need to replace White to Transparent. How I can do it programmaticaly?
This is probably not as easy to do programmaticaly but it is easy to do in an image editor. I always do it in paint.net. You can download it here: http://www.getpaint.net/download.html
This youtube video describes how to do it: https://youtu.be/cdFpS-AvNCE
It literally takes less than a minute to do and is what I have used on a lot of my projects.
The color you set by ImageView.setBackgroundColor method shows up only where the src image have some transparent pixels or some spaces of ImageView that is not covered by the src image because of scaleType And I'm not sure you want to process images in your code in order to replace back color with transparent color, So the right way to achieve that is to use some Photo Editor softwares to edit images before using in your app.
First, you'll have to remove the background from the original photo using a photo editor like GIMP ,be sure to save the file in an Android supported format that supports transparency (PNG).
Next, inside the XML layout file (or in code), put the drawable view itself inside a FrameLayout.
Finally, call View.setBackgroundColor() on your FrameLayout.

Resizing bitmap image within imageview

I have an imageview that displays a photo taken with the phone's camera, which can be changed by the user. The problem I'm having is that the picture is scaling too small within the imageview, is there a way to force the bitmap to fit the imageview completely?
Next time, please search a few minutes, before you ask a question!
In the layout xml-file you have to add the following attributes to your ImageView to make it fill out the view:
android:scaleType="fitCenter"
You can find the attribute in the ImageView documentation's list of XML Attributes. The different scaleTypes can then be found by clicking "android:scaleType" to get to its description.

Image that has multi clickable zones/surface/area

I want to have an image on the android screen where different parts of the image can be clickable. What I mean is that, If its an image of 3 circles, I want to be able to click each of these circles,
Then I can add different functionalities to each of these clickable circles.
For an instance in this image below I want to be able to click each distinct color. Is it possible to have on-touch-listener and get you the color ? and can it be an image or has to be drawn in Java OR XML ?
I found a really good widget that helps you make any image muli-clickable. They have some good notes on how to use their widget as well.
The widget has a similar approach as Image mapping in html. The good thing about this widget is that the image can be zoomed and it will not lose the coordinates or areas associated to specific clicks.
Here is the link to their website. the guy who made the widget apparently had similar problem and came up with this widget.
Another solution would have been
creating an ImageView containing the png file referenced
making the whole ImageView clickable
setting an OnTouchListener to the ImageView which overrides the onTouch method
check the colors of the image pixel at the touch position
This is often done with an invisible mask image with one color for each zone (see the popular detailed tutorial), but here the image itself has distinct colors for each zone which makes it more interesting.

Android border layout with an EditText overlapping on it

I want to code a layout like the following image in xml in Android.
One approach would be to have a RelativeLayout and make a 9 patch rounded rectangle border image, have it as the background around a layout which has the two blue buttons, and then have and EditText overlapping it, with its background set to a red color.
What could be other approaches?
As I understood your question you want to make series of photos ..like Gallery application
you can do it with more option also.
1)this is gallery type application .
so . you can use this basic code :Android Gallery Application
2)If you want to see all the photos in circle this is also possible..
It depends upon your need ..please write in brief you want more...

Categories

Resources