I am having problem with custom seek bar I am not getting same as i expect, I am using 2nd image as progress drawable and first as thumb, but when i use wrap content it is small and when i use fill parent it is repeating and the seek bar different from the 2nd image in the UI?
You should use Nine-path graphics. With this android will automatically resize your image based on borders you provide in graphics.
set maxHeight and minHeight of seekbar properties.
example:
maxHeight = 40dp
minHeight = 40dp
Related
Trying to arrange my UI and I can't seem to remove the spacing around my slider. It's a basic Material Slider (pictured below). I've tried changing minHeight & minWidth with no luck & I'd prefer not to pad negatively. I assume there must be a way to make the slider's bounds just be around the actual slider image.
See Slider Example
The height of the slider is controlled by the dimension R.dimen.mtrl_slider_widget_height. You can change the height by specifying in dimens.xml
<dimen name="mtrl_slider_widget_height">30dp</dimen>
Or whatever height you would like. There are some other resources loaded in the BaseSlider.java that may be helpful.
private void loadResources(#NonNull Resources resources) {
widgetHeight = resources.getDimensionPixelSize(R.dimen.mtrl_slider_widget_height);
minTrackSidePadding = resources.getDimensionPixelOffset(R.dimen.mtrl_slider_track_side_padding);
trackSidePadding = minTrackSidePadding;
defaultThumbRadius = resources.getDimensionPixelSize(R.dimen.mtrl_slider_thumb_radius);
trackTop = resources.getDimensionPixelOffset(R.dimen.mtrl_slider_track_top);
labelPadding = resources.getDimensionPixelSize(R.dimen.mtrl_slider_label_padding);
}
I have created a style that extends the material seekbar in android to make the horizontal bar thicker I would also like to increase the size of the thumb that is dragged. I don't want to change the thumb just use the normal #drawable/scrubber_control_material_anim.
I got a picture that I want to use.
I set it as following:
ImageView menu = new ImageView(this);
menu.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT));
menu.setImageResource(R.drawable.menu);
They annoying thing is that I get white pixels on the sides of it cause I want to keep the aspect of the pic.
I can stretch the image by using menu.setScaleType(ScaleType.FIT_XY); but that will make the person on it look really fat. The picture is dark and the pixels are white so they do show quite well. :/
Is there I way I can first apply black color and then the image above that color?
To set a background color to any view on android you can use android:background attribute in layout xml or by calling setBackgroundColor(int id) in java code.
But if you really want just to set the image in bounds you can give a try to android:scaletype="centerCrop"
Using set BackgroundColor will also remove any padding, borders and what not attached to the object.
If that is the result you want, that is a reasonable approach.
If blasting the objects current style will cause problems, I would look to use CSS to set the background color and change the css styles through code if things are happening after page load.
Consider using a border around the image that is colored the way you want to hide what is underneath?
i am using a custom notification layout. Notification layout is inside an activity. Notification layout does not fill the entire portion of the screen. It takes only 1/4 of the screen. I want to show the progress bar inside the notification layout.so my question is
How to set the position of progress bar(other than using
(ProgressDialog.getWindow().setGravity(Gravity.CENTER);)
Can we set the width and height of progress bar( atleast to the size of the layout)
Any help is highly appreciable.
"How to set the position of progress bar": use it like any other types of View (xml will be simpler).
"Can we set the width and height of progress bar( at least to the size of the layout)":
android:maxHeight An optional argument to supply a maximum height for thisview.
android:maxWidth An optional argument to supply a maximum width for this view.
android:minHeight
I'm trying to make a timeout gauge bar animation effect:
The width of a lengthy colorful bitmap image is decreasing, but not x-scaling.
so the image looks not changing and the visible area shrinks.
I couldn't find the sole ImageView clipping or masking support in android.
And I managed to get the clipping effect by surrounding the ImageView in ViewGroup like:
<FrameLayout android:id="#+id/shrink_box" ...>
<ImageView android:src="#drawable/still_image" ...>
</FrameLayout>
then changing the shrink_box's width will clip the portion of the still_image.
But I failed to change the width of the view smoothly.
I tried to change the LayoutParam.width in applyTransformation() but got an Exception, it seems not allowed.
How can I make an Animation that changes the width of the view. OR is there a proper method to achieve the above effect?
You are trying to reinvent the wheel here, just use a ProgressBar and set the progress drawable to your image.
In your xml layout give the ProgressBar this style to make it an actual bar rather than a wheel
style="#android:style/Widget.ProgressBar.Horizontal"