Android seekbar discrete, how to remove step indicator - android

I've just discovered the seekbar discrete widget in android studio, i found it very usefull but i can't figure out how to remove the step indicators, or changing them with more appropriate drawables.
Did someone managed to do it?
Here's a screen of my current seekbar:
I'd like to change all the current step indicators, thank you.
EDIT:
Here's my current progress drawable:
<item android:id="#android:id/background" >
<shape >
<corners android:radius="20dp" />
<gradient
android:startColor="#color/Trasparente"
android:centerColor="#color/Trasparente"
android:centerX="1"
android:endColor="#color/Trasparente"
android:angle="0"
/>
</shape>
</item>
<item android:id="#android:id/progress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<corners android:radius="20dp" />
<gradient
android:startColor="#color/colorBluClima"
android:centerColor="#color/colorGreenServizi"
android:centerX="0.35"
android:endColor="#color/colorRossoErrore"
android:angle="0"
/>
</shape>
</clip>
</item>
and here's my seekbar in the layout:
<SeekBar
android:maxHeight="12dp"
style="#style/Widget.AppCompat.SeekBar.Discrete"
android:layout_width="812dp"
android:layout_height="100dp"
android:max="19"
android:id="#+id/SeekBarStufa220"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="90dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginEnd="90dp"
app:layout_constraintRight_toRightOf="parent"
android:paddingEnd="85dp"
android:paddingStart="85dp"
android:progressDrawable="#drawable/progress_seek_clima"
android:thumb="#drawable/ic_temprature"
app:layout_constraintVertical_bias="0.79"
android:progress="10" />
The thumb is a simple drawable

I solved it creating a new style with SeekBar.Discrete as parent.
<style name="SeekBarWithoutSteps" parent="Base.Widget.AppCompat.SeekBar.Discrete">
<item name="tickMark">#null</item>
</style>

if you want want to use style, you can use below xml attribute for material sliders to hide the dots
app:tickColor="#00000000"

I was searching for same solution, but for Material Design Slider (com.google.android.material.slider.Slider)
.
I don't know since this option is available (currently i'm using 'com.google.android.material:material:1.3.0' ), but if you use code below in your layout XML, ticks will disappear.
app:tickVisible="false"

I was also searching for an answer to this but didn't find anything. I tried some things and found a style included in Android Studio (I am sure it will be also available in Eclipse and other IDEs) within the Discrete SeekBar options which is #android:style/Widget.DeviceDefault.Light.SeekBar.
I tried it with an Android 5.1 device and it worked perfectly, but be careful cause there's one which could seem to be the same (called #android:style/Widget.Material.SeekBar.Discrete) but it leaves the dots.
So I think that if the first one removes the dots from the SeekBar, it's the one you were looking for.

Related

Android scrollindicators style / color android

android:scrollIndicators="top|bottom"
does provide scroll indicators, but they are barely visible at all.
Screenshot of barely visible Scrollindicators
What theme/style color are they using, or how can I assign a custom color?
You can customize the scroll bar by changing its width and setting a custom shape.
Add following tags in your scroll view
android:fadeScrollbars="false"
android:scrollbarStyle="insideInset" // set as required..
android:scrollbarTrackVertical="#drawable/vertical_scrollview_track"
android:scrollbarSize="20dp"// set as required width..
Create following drawable in your drawable folder
vertical_scrollview_track.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#E2E0EB" />
<stroke
android:width="1dp"
android:color="#b3a9a9" />
<size android:width="15dp" />
<corners android:radius="15dp" />
</shape>
change colour as required.
<style>
<item name="android:colorForeground">#FFF</item>
</style>
As with SwitchCompat's track, a low opacity / high transparency version of colorForeground is used. Setting it to full white (or black on light backgrounds) makes the scrollindicators at least a bit more visible before someone finds the real solution.

How to get dashed Horizontal Progressbar in Android?

I need to design a dashed progressbar as shown in attached.
This is what I have done so far, It displays a normal progressbar with two different colors, one for progress and another for other.
<ProgressBar
android:id="#+id/progress_bar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:progressDrawable="#drawable/bg_progress_bar_green"
/>
And bg_progress_bar_green is here
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<solid android:color="#E0E1EA" />
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape>
<solid android:color="#66BA6B" />
</shape>
</clip>
</item>
And this is how I update the progressbar :
progressBar.setProgress(numOfHours);
How do I get dashed line of bar as shown?
You can use this library for your work Step Progress Bar. I'm providing code in case of link changed.
Gradle
dependencies {
...
compile 'com.marcok.stepprogressbar:stepprogressbar:1.0.1'
}
Usage
<com.marcok.stepprogressbar.StepProgressBar
android:layout_centerVertical="true"
android:layout_height="0dp"
android:layout_width="wrap_content"
android:id="#+id/stepProgressBar"
app:cumulativeDots="false"
app:activeDotIndex="0"
app:activeDotColor="#color/material_deep_teal_500"
app:inactiveDotColor="#color/material_blue_grey_800"
app:activeDotIcon="#drawable/active_dot.png"
app:inactiveDotIcon="#drawable/inactive_dot.png"
app:numberDots="6"
app:dotSize="20dp"
app:spacing="20dp"/>
If dot icons are provided, they override dot colors
Layout height is irrelevant and determined by the dotSize
Java Code
To move to the next dot or previous dot:
StepProgressBar mStepProgressBar =(StepProgressBar)findViewById(R.id.stepProgressBar);
mStepProgressBar.next();
mStepProgressBar.previous();
To set the dots to be cumulative (all dots <= the specified index will show as active), call setCumulativeDots(true)
Calling setCurrentProgressDot(-1) will prevent any dots from showing as active. Any lower values will throw IndexOutOfBoundsExeption.
Other methods:
setCurrentProgressDot();
setNumDots();
setActiveColor();
setInactiveColor();
setActiveDrawable();
setInactiveDrawable();
DRAWABLES FOR RECTANGLE PROGRESS
use these two drawbles..
inactive_dot.png
active_dot.png

Override theme color for touch highlight, scroll hinting

I am trying to substitute and override the default touch highlight color of the theme for the corporate ones.
I have successfully done it for the actionbar buttons by using actionBarItemBackground on my theme properties, but I am looking at an application-wide change where every pressed element in buttons, actionbar, drawer or menus defaults to my color instead of the Holo blue. I have tried properties like colorPressedHighlight. colorFocusedHighlight but none worked.
I would also like to change the color of the scroll end hinting, the little gradients on the sides of a scrollable element when it has reached one end and the uses is still attempting to scroll.
Given the high volume of incorrect answers, let me restate again. I know what a selector is, I know how to use it, I have explicitly stated that I have overriden the theme with several different subproperties but none does what I asked for. I am looking for the property to change both the default touch highlight for all elements, and the color for the scroll cache hinting, again for all elements.
To change the end-of-scroll hint you can try this library for a fancy solution, or just the code below for a quick solution(code source and explanation):
static void brandGlowEffect(Context context, int brandColor) {
int glowDrawableId = context.getResources().getIdentifier("overscroll_glow", "drawable", "android");
Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
androidGlow.setColorFilter(brandColor, PorterDuff.Mode.MULTIPLY);
}
Note that both of these are a bit hacky fundamentally as they works on platform drawable resources that are not guaranteed to stay the same between Android releases, though the plus note is that these resources have not been renamed from 1.0 to KitKat.
I found the answer here: https://stackoverflow.com/a/9062723/1266326
The name of the component is not scroll hinting but overscroll.
What you want to do is add a custom_color.xml file to your apps drawables folder. You can name it what ever you want and it might look similar to
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#004F81"
android:endColor="#004F81"
android:angle="270" />
<stroke
android:width="3dp"
android:color="#004F81" />
<corners
android:radius="3dp" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:endColor="#004F81"
android:startColor="#004F81"
android:angle="270" />
<stroke
android:width="3dp"
android:color="#004F81" />
<corners
android:radius="3dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:endColor="#43AFE8"
android:startColor="#43AFE8"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#43AFE8" />
<corners
android:radius="6dp" />
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp" />
</shape>
</item>
</selector>
Then in all of your layout xml files just set the back round of each element to your custom back round
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/custom_color"
android:textColor="#FFFFFF"
android:text="Button" />
I am currently implementing this and it works quite well.
You can read here about the State List.
Basically what you'd want to do is create a selector that overrides the color with your color and then create a theme that is a "child" of the default holo theme and change the elements you want to change the color for with your selector. This will give you a more application wide solution.
Read about the Style and Themes here.
I guess the right answer would be "No, there isn't a theme attribute you can override in your own themes that will magically change the highlight color across your app's Activities and Fragments". Or, in my case "No, there isn't a theme attribute you can reference to get your current theme's highlight color".
As to "Why?", I guess it's because Google itself doesn't use a theme attribute across all of the standard UI widgets (TextView, EditText, Button, ListView, etc.) because they rely on PNG drawables (9 patches) and not only on state lists.
Great question, though.
You can set up your styles here: http://android-holo-colors.com/
Then download, integrate and set it in your app.

Android - button background color shrinks the height of the button

I have this button
<Button
android:id="#+id/learn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop ="5dp"
android:text="Hello StackOverflow"
style="#style/home_page_buttons"
/>
and I am trying to give it this style
<style name="home_page_buttons">
<item name="android:layout_marginLeft">15dp</item>
<item name="android:layout_marginRight">15dp</item>
<item name="android:textColor">#color/light_best_blue</item>
<item name="android:textStyle">bold</item>
<item name="android:color">#color/white</item>
<item name="android:background">#color/white</item>
</style>
This line:
<item name="android:background">#color/white</item>
makes the backgrond white as I wanted, but for some reason, it shrinks down the height of the button and makes it ugly.
Any idea why that happens and how to stop this side effect?
Thanks!
ABDOU is right, this could be a solution for you
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FFFFFF" android:endColor="#BBBBBB"
android:angle="270"/>
<stroke android:width="2dp"
android:color="#555555" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="7dp"/>
</shape>
Create this as XML in drawable, and set this to your BackgoundColor
The default button has a fixed minimum height, which is equal to the height of the underlying image. Here, since you are using a color, it has no minimum height. So, it takes up the height of the text. For your case, you will have to fix the height of your buttons.
A better way is to use custom button images.
when you make style="#style/home_page_buttons" you change the default style of the android button
if you want keep it, just make a background image for your button
I do not know if this is version dependent or due to any recent changes Since I have a very recent version of Android Studio, but I seem to have at least some degree of success restoring the extra space by specifying the Padding attribute.
Simply by adding this attribute:
android:padding="5dp"
The Button will regain most of that space it lost. I Recommend tuning the number, or possibly splitting the Attribute up into its 4 Directional Variants to customize the spacing to however much you want.
This seems to also apply for EditText as well as Buttons, as both appear to have the same problem.

Add Frame or Border to ImageView and Drop-Shadow

What I'm trying to do will work better with an example image. As you can see below I have a grey background, ontop of that sits a container with some padding containing an image. The container also has a slight dropshadow to it.
What I want to know, is if there's so non-painstaking way of doing this in my layout.xml? In a normal HTML document this would've been easy. But since this is for a mobile app and for a number of screen resolutions and so on, it's proving a bit difficult.
Any advice?
Edit: I eventually settled using a 9patch image. Everyting went really smooth in the creation of it but when I actually use it in my app I see these dark stripes on the right and bottom of the image. The dropshadow seems to work, it's a very light dropshadow.. but those darn stripes??
You can provide a border to a view by writing an xml file (say editBorder.xml) in drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="5dp"
android:color="#EBDDE2" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="4dp" />
<gradient
android:centerColor="#color/white"
android:endColor="#color/white"
android:startColor="#color/white" />
<corners android:radius="8dp" />
</shape>
and to provide this border, use statement in ImageView as android:background="#drawable/editBorder"
This should solve your problem. :)
This can be done with proper padding and 9 patch image. See this link, may be it can help you.
ImageView having two property android:background and android:src
http://developer.android.com/reference/android/widget/ImageView.html
Create a blank white frame with drop shadow(Photoshop recommended).
So just do this
<ImageView android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image"
android:background="#drawable/whiteFrame"
android:padding="10dp" >
</ImageView>
I found this imageView . It's may good for you

Categories

Resources