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...
Related
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.
Goal: A highlighted section of an image (the image covers the whole screen). The rest of the screen needs to be faded out.
Example
So far I've got the fading working using the foreground of a FrameLayout and placing the image as the background of a RelativeLayout within the FrameLayout. The solution I'm thinking is that I need to create 2 Drawables and merge them into one that FrameLayout Foreground can consume.
I've also been reading a bit up on PorterDuff, but I think that may be overkill for what I'm trying to achieve.
The fade functionality is working fine, but the source of the fade with transparent section is not.
I suggest that you have the original image in an ImageView on top of it place 4 views which are partially dimmed and that's it!
With some basic math you can know the sizes for each view, and using RelativeLayout will allow you to easily place them on the screen.
Good Luck!
P.S. I've attached a sketch to illustrate what I'm suggesting.
I'd like to create a textview that contains a blue line as it's background just like in the image I provided. You can also find it in Google calendar when entering appointment info.
I previously tried using 9patch images to stretch the line horizontally and keep the vertical scaling the same. But that does not work. I'd like to also use this in other view to provide my own background to other views. Any hints?
Thanks you in advance!
I believe that you are looking for the EditText layout item, not TextView. It will automatically change the line to the blue color when the user places the cursor there, otherwise it will be black.
you can use a relativelayout for your edittext, and for the lines, a view 1dp high at it's bottom (width matchparent so it stretches) , and two 1dp wide views at its sides, that'd accomplish that effect (as high as you want them).
I couldn't find a similar example as close as the Google chrome logo. I want to make this logo using Android, forget about the colors or exact design. Imagine the blue dot is an ImageView, the red,green and yellow are ImageButtons. I want an ImageView surrounded by 3 or 4 ImageButtons like this. All what I came up to is the Oval layout shape with ImageView centered. I only need a hint if anybody has.
http://en.wikipedia.org/wiki/File:Chrome_Logo.svg and http://upload.wikimedia.org/wikipedia/commons/e/e2/Google_Chrome_icon_%282011%29.svg are SVG versions of the chrome logo. You should be able to get quite exact coordinates from those.
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.