Customizing the Android NumberPicker - android

In Android 4.0 is there a way to change the colour of the blue lines above/below the EditText in the stock NumberPicker Widget? I have not found a way to change the colour in the xml and am wondering if anyone else has found a way to do this without creating a completely custom widget. Thanks.

I can't see any blue line in the current NumberPicker, though it is a layout and the line is probably an ImageView on fixed indexes i1,i2,... ,therefore you can use
View v = picker.getParent(i);
and modify the returned view or alternatively remove it completely.

Related

How is the line under the text of an EditText created?

By default android.widget.EditText has a line under its text. How exactly is that technically done? I checked the source code of the EditText class, but couldn't find where this is done?
I think to know that the line is technically a background, but where is this background set? And especially, as it's just a background, how does Android ensure that this line is drawn below the text and not behind it? Answers with proofs / links to source highly appreciated.
yes, this underline is a background, which is probably ColorStateList (e.g. it changes color when pressed), but if you run your code on Android 4.x or older (pre Material Design) then this background is fixed bitmap/drawable
EditText have an android:background attribute, but it is also present for all other Views. so it is set inside source code of View, not extending EditText. and pointer to the proper drawable of background is set by styling/theming (in HERE you have some example)
EditText is using TextPaint (getPaint method) which may be used to add some extra spacing between/over/under/next to letters to ensure not-overlaying. also drawable may have padding attribute - may draw line in last row of pixels but set bottom padding to 1px and that ensures that content of this View (in this case EditText) will not be drawn under/over padding (but drawable does) - sooner View will expand a bit if have wrap_content for height
sorry for not-so-precise answer, topic needs more inwestigation and searching in sources, but maybe my points will help you find answers by yourself

Customize textview in android

I want to customize my textview as per my requirement. I have to add padding or margin dynamically when text is too long and it should look like my screenshot which I have attached here. Can anyone help me how can I implement it and below is my screenshot.
Try using this. It is customizable.
I used it so that I can have different color texts inside my "textview" , and also I used it, cause I did on it a code to resize the text size, so that it fits in the screen height. But if that was possible, I'm pretty sure what you want to do is also possible.
https://github.com/DavidPizarro/AutoLabelUI

AppCompatButton get background color (colorButtonNormal/colorAccent) in code (Lollipop v21+)

I've got code that iterates over views, after inflation, so I can hotswap certain colors.
The problem I'm facing at the moment is reading the current color used by, for example, a AppCompatButton runtime. I know that it's being colored by my AccentColor in some cases, but I don't know where to find that color programmatically on the View.
I've been using reflection and checking the private fields of the RippleDrawable (AppCompatButton.Background) and its children. But I'm coming up blank. I can't find the color and ColorStateLists are empty, Tints are null, Paint objects have White as the current color, etc.
I've been going over the Android source code on GitHub but I haven't found the solution yet, any help would be appreciated.
To clarify, I know what colors are being used, but I need to check if a specific AppCompatButton is using a specific color or not.
Update 1
It appears that the following two xml defines the AppCompatButton:
btn_default_material.xml
btn_default_mtrl_shape.xml
The second xml defines a shape with a android:tint="?attr/colorButtonNormal", that would be the GradientDrawable I was trying to extract information from.
I'll give it another go tomorrow and see if I can't extract the tint from the GradientDrawable...
I found the color, in my specific case and Android OS version. It was mColor, inside mTintFilter, inside the GradientDrawable.
Hierarchy: AppCompatButton.Background.GetDrawable(0).Drawable.mTintFilter.mColor

Android change TextField outline/boarder color

I have a text field, and on Android 2.2, when it is in focus or being used, it highlights it and puts an orange boarder around it.
The orange really doesn't look good with the other colors in my app, so I am wondering if there is any way to change that to a different color...
Thanks in advance.
You can write selectors for your textview using which you can change the appearance of your textview when it is selected.
You can refer to this:
http://developer.android.com/reference/android/content/res/ColorStateList.html

android how to change the progressbar color programatically

How can you change the progressbar color from within the app. I already have it set in the XML but as the value gets within preset thresholds I need to change the color of the bar to alert the user. For the buttons I can set it like the example below. Is there a way to do with with the progressbar?
B.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.button2));
B.getBackground().setColorFilter( UserS.ColorBtnBack, PorterDuff.Mode.MULTIPLY);
I posted a tip as a comment on your other question, see http://colintmiller.com/2010/10/07/how-to-add-text-over-a-progress-bar-on-android/
Scroll down to "Bonus Tip", which discusses changing color. I guess you want a predefined set of colors, which you could then switch between using setProgressDrawable()
ProgressBar uses a LevelListDrawable with setProgressDrawable() to determine the color of the bar. You can try assembling a LevelListDrawable in Java, though I have never tried that -- I have only defined them via XML.

Categories

Resources