I would like to know if it is possible create this in android studio for
layout background of my activity.
Reapet a drawable and move in a direction.
You can try adding this dependency to add gif animation:
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
and use FrameLayout.
As an alternative, consider the using the MotionLayout widget to manage motion and widget animation.
This can be done in many ways:
Animated Vector Drawable as the android:background
Animated Gif
Object Animators
MotionLayout
1
There is many ways to create this.
The most elegant and efficient solution is an an animated vector drawable.
But it is also difficult to get all the information together to do it.
2 This Gif will be big or blurry and a resource hog. but simple to implement
3 ObjectAnimator straightforward create a collect of (about 6)black views , rotate 45 degrees
and use a series of ObjectAnimators to translateX/Y
4 MotionLayout would allow this without code and mostly in studio
Create A Constraint Layout
drag 6 black views, rotate and Position them using the Attributes
Convert to MotionLayout
In the "End" ConstraintSet Modify TranslationX & TranslationY
Set Transition to AutoStart
Create A Transition to AutoJump back to the end.
Related
I've been trying to create a bar chart/ loading bar where the text is half one colour and half one another and have been struggling to come up with a simple way to tackle this. My ideas thus far have revolved around creating both bars in their complete state and then having a pair of 'selective transparency' views which would show the respective halves to create the effect.
I've been unable to find how to do this selective transparency/ opacity view. Is this possible? Is there some other blindingly obvious way to achieve this effect?
Here's a quick drawing of what I'm trying to achieve.
For anyone stumbling across this, I managed to solve this by using setClipBounds. I did it by creating two textviews of the full size, one with a coloured number and transparent background and the second with a white number and coloured background. Then setClipBounds is applied to the coloured textview as follows -
textview.setClipBounds( new Rect(0, originalHeight*(1 - progress), originalWidth, originalHeight);
Here, the variable progress has a value between 0 and 1. The Rect has to be defined relative to the view, not relative to the screen.
This exact setup achieves an effect something like this, but it could easily be changed to a horizontal bar or whatever else is required.
Somehow misinterpreted the question. The best way to achieve this would be to create the images and set as background to an imageview instead of a textview.
You could just use a LinearGradient
With the parameters colors and positions you can indicate the loading progress.
You can use the gradient when you override the onDraw Custom Drawing
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 am working in Indoor Positioning System .. It will be an android app like this
I am trying to make custom View for displaying the map, First step I make a Scrollable ImageView following article called 'A simple implementation of a scrollable ImageView'
The problem is when I put a marker in the map (using another ImageView for marker), When I start scrolling .. the markers start disappearing like this
So can any one help me ? I want markers to stick into the map and only the map scroll (I mean like Google Maps)
For creating map, Canvas is a better option, in canvas you can implement scroll,zoom,rotation etc.
In canvas it supports any number of bitmaps, and also we can draw programmatically within the canvas.
So, I'm working on a main menu activity for my android application.
I want to create background animation where there are things translating from the top of the screen to the bottom. The x position and translation speed of each will be random (within some limits).
I have created a new thread to run this animation (so the UI doesn't get slow or messed up).
I do not want to use a SurfaceView if possible. I'm planning on using an ImageView resource, then using .startAnimation(animation), where animation is a translational animation resource.
My problem:
Is it possible for me to create multiple instances of the same ImageView, if I wanted to run multiple animations at the same time (3 of the same ImageViews falling at different rates and different x positions)?
How do I set the starting point of each of the ImageViews to be at some specific x position? For me to specify an absolute starting point, which type of layout would be required?
Any help is appreciated.
I think I've just decided that a linear layout placed on top of a surface view is the best option. The animation would just be drawn on the surface view while the regular menu interface is contained in the linear layout.
Update:
Used a FrameLayout with a SurfaceView and LinearLayout inside. It works perfectly.
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.