How to have numbered scale with Seekbar (Android)? - android

I am trying to customise Seekbar. I need Seekbar like :
How do I add numbered scale to Seekbar as shown in image above?
I have been able to make custom thumb and custom progress drawable simply by using their vectors, in XML, as:
android:thumb="#drawable/custom_seekbar_thumb"
android:progressDrawable="#drawable/custom_seekbar_progress"
android:splitTrack="false"
But I have not been able to use the numbered scale as shown in the image.
Some answers on stack overflow say about how to draw numbers above/below Seekbar, but I couldn't find any information on how to draw the vertical line (|) below each number.
Any help would be appreciated. Thanks!

There is a method setTickMark and xml attribute android:tickMark that can be used to draw vertical lines. But there are two problems. The first one is it is only available in api 24+. The second one is that all the ticks would be the same and in your design they are different.
Unless you find a library that does exactly what you need, your best option is to create a custom view by subclassing/copying SeekBar and customizing the onDraw method.

Related

How to create round shape image using android?

I am having four piece of image.
Here I attached one sample image.
How can I create the round shaped image using these type of images?
Which layout is best for creating the UI for android?
Thanks in advance.
are you talking about something like this..
http://www.baijs.nl/tinycircleslider/
And for designing the UI for Android is depends on our requirement.it means whether you want to design something looks like rows and columns then GridLayout and tableLayout will be better,depends on requirement and look the layout will changes once try it your self and choose the best suited for your applicaiton.All the best Mate
inside relative layout add four imageview with attrs ParentTop, ParentRight, ParentBottom and ParentLeft. every image is rectangular with transparent extra area.
i can understand it is little hard to visualize on first attempt.
now come to click area. so a runtime decision about ignore transparent area click will be right thing.
more tricky way will be manage flags for all listeners and if two listener get calls its transparent area .

Draw a gradient filled polygon to use in a selector

I am trying to create a drawable such as this in Android:
I don't think a nine patch will work because there is nowhere that can safety scale vertically. So next I tried a shape drawable but it does not support triangles.
I want to render this image on the fly so there are no artifacts. Also I want to be able to use it in a selector, so I need to be able to represent this image in xml. Maybe I need to extend some class to manually make the shape. If so how do I embed a tag in the xml to tell it where to render? Does anyone know where to start with this or have an example of something similar?
I have read the first 10 pages of hits on stack overflow and google and am not getting anywhere. Thanks very much for any help.
I think a 9-patch would work. For the vertical stretching on the left boundary, fill in the line from top to bottom.

How to set borders for a drawable that repeats horizontally?

I'm using a layer-drawable and inside it I have one BitmapDrawable that repeats only horizontally. But I need to add borders for this drawable.
But I didn't find any solution for this!
I tried to create a ShapeDrawable and set my BitmapDrawable as background of my ShapeDrawable, but it's not possible.
I tried to find a method that add borders for my ShapeDrawable, but I didn't find it.
I also added 2 other images, that would be the box_top_left and box_top_right.
With this idea, I only need now to make it appear in this order:
box_top_left, box_repeat, box_top_right.
But i'm also having trouble to do this!
I've found a several ways to change a drawable's padding in my xml but not during the execution. I can't just set it on my xml because I don't know the total width.
And I didn't find any way to make my drawable the exactly width of my image.
Can somebody help me, plz?
I'll post some images to help you to understand what I want to do.
The first image is how it should be:
Inside my Dialog, at the top, above the text "Acesso ao sistema" I have my image that sould repeat.
I used a layer-drawable for my Dialog's background with a item that is the shape for my dialog and another item that should have my BitmapDrawable repeating only horizontally.
This second image is only missing to add my box_top_left and box_top_right.
This third image is what happens when I don't use borders:
And the last image is third image expanded for you to see the problem:
Thanks for your attention.
I think using a nine-patch for this will make your life a lot easier.
I think you can try Layer List, and define two items. One item is a shape which you can add stroke to be the border, and the other one is a bitmap which you can set tileMode to be "repeat" to repeat.
I used this method to implement my task. And I ran into one problem which already was fixed.The bug is that the repeat area seems have some lines between images.This may be caused by the shape having default black background. So I set the shape item's color to transparent.
Hope this will work for ya~~

what is the use of shadow

What is the use of shadow in Android?
How do I implement shadow in thumbnails?
If someone has a sample screenshot, do you mind sharing it?
Shadows can be added to TextViews through XML or programmatically.
If you'r wanting to add a shadow to a standard view (or any subclasses) this thread should point you in the right direction.
Not knowing what are your objects could be tricky. you can define what's the background in the picture and filter it, then you can strech your image in the direction of the shadow. now filter everything but the background, so you've got 3 layers - background, shadows and objects. place the shadows on the background and on top of that the objects.

Is it possible to have a SeekBar's thumb image extend outside the bar?

I have set negative paddings on my custom seekbar so that the round thumb image can go outside the bar, but the thumb isn't rendered out there, is there anyway to force the thumb to be drawn outside those bounds?
Sorry guys, I'm new to Android development, and have been tasked with fixing an existing application. The problem is that we have a custom rounded looking track bar, which consists of two rounded 'end cap' images and a 1 px background that is tiled to create the seekbar. As far as I can tell there was never one image that could be set as the background of a normal SeekBar, which is why a custom one was created.
The thumb is a circle and needs to 'fit' into the end caps - the three pieces of the bar are in a relative layout. Right now I'm kind of unclear as to how the 1 px background png gets stretched as the seekbar bg, otherwise I would try to tack on the two endcaps onto that drawable some how ... ?
Please let me know if this was unclear and I'll try to post any followup info. Thanks in advance for any advice!!
Oh, I'm using Android 2.1 if that's relevant to anyone's interests :)
This is what it looks like when the thumb all the way over - outside of the seekbar. Ideally what I need is for the thumb to be shown as 'inside' the endcap image :-/
I was having the same problem, my thumb is very big length wise and it kept being cut off. Make sure that you set the offset property AFTER you set the drawable for your thumb, like this:
seek.setThumb(Main.app.getResources().getDrawable(R.drawable.thumb));
seek.setThumbOffset(15);
This will set the correct offset when your thumb is very long.
Try to change the thumb offset property, after that it will not go off from the seek bar
I just ran into this issue. I was able to get satisfactory results by using android:paddingLeft and android:paddingRight within the XML.

Categories

Resources