Text color of a closed spinner

To modify the text color create a new xml file in your res/layout folder (for example my_spinner_text.xml). Add a text view to the new xml file and modify how you want: <TextView android:id=”@+id/spinnerText” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:textColor=”#CCCCCC” android:textSize=”20dp” xmlns:android=”http://schemas.android.com/apk/res/android”/> Create an ArrayAdapter that uses the new TextView and set it to your spinner: Spinner localSpinner … Read more

Setting font color of JavaFX TableView Cells?

You need to override the CellFactory. Partial code just of the third column: TableColumn thirdColumn = new TableColumn(“Third Column”); thirdColumn.setCellValueFactory(new PropertyValueFactory<TableData,String>(“three”)); // ** The TableCell class has the method setTextFill(Paint p) that you // ** need to override the text color // To obtain the TableCell we need to replace the Default CellFactory // with … Read more

Is it possible to change the text color in a string to multiple colors in Java?

Yes, its possible. For this you need to use SpannableString and ForegroundColorSpan. This should look something like this: SpannableStringBuilder builder = new SpannableStringBuilder(); String red = “this is red”; SpannableString redSpannable= new SpannableString(red); redSpannable.setSpan(new ForegroundColorSpan(Color.RED), 0, red.length(), 0); builder.append(redSpannable); String white = “this is white”; SpannableString whiteSpannable= new SpannableString(white); whiteSpannable.setSpan(new ForegroundColorSpan(Color.WHITE), 0, white.length(), 0); builder.append(whiteSpannable); … Read more

UILabel with text of two different colors

The way to do it is to use NSAttributedString like this: NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString: label.attributedText]; [text addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(10, 1)]; [label setAttributedText: text]; I created a UILabel extension to do it.

Change the text color of a single ClickableSpan when pressed without affecting other ClickableSpans in the same TextView

I finally found a solution that does everything I wanted. It is based on this answer. This is my modified LinkMovementMethod that marks a span as pressed on the start of a touch event (MotionEvent.ACTION_DOWN) and unmarks it when the touch ends or when the touch location moves out of the span. public class LinkTouchMovementMethod … Read more

Use multiple font colors in a single label

Reference from here. First of all initialize of you NSString and NSMutableAttributedString as below. var myString:NSString = “I AM KIRIT MODI” var myMutableString = NSMutableAttributedString() In ViewDidLoad override func viewDidLoad() { myMutableString = NSMutableAttributedString(string: myString, attributes: [NSFontAttributeName:UIFont(name: “Georgia”, size: 18.0)!]) myMutableString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSRange(location:2,length:4)) // set label Attribute labName.attributedText = myMutableString super.viewDidLoad() } OUTPUT MULTIPLE … Read more

Change the text color of NumberPicker

The solution I tried and worked for me is: In styles.xml add: <style name=”AppTheme.Picker” parent=”Theme.AppCompat.Light.NoActionBar” > <item name=”android:textColorPrimary”>@android:color/black</item> </style> Then use it like this inside your layout: <NumberPicker android:id=”@+id/dialogPicker” android:theme=”@style/AppTheme.Picker” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”15dp” />

How can I change default dialog button text color in android 5

Here’s a natural way to do it with styles: If your AppTheme is inherited from Theme.MaterialComponents, then: <style name=”AlertDialogTheme” parent=”ThemeOverlay.MaterialComponents.Dialog.Alert”> <item name=”buttonBarNegativeButtonStyle”>@style/NegativeButtonStyle</item> <item name=”buttonBarPositiveButtonStyle”>@style/PositiveButtonStyle</item> </style> <style name=”NegativeButtonStyle” parent=”Widget.MaterialComponents.Button.TextButton.Dialog”> <item name=”android:textColor”>#f00</item> </style> <style name=”PositiveButtonStyle” parent=”Widget.MaterialComponents.Button.TextButton.Dialog”> <item name=”android:textColor”>#00f</item> </style> If your AppTheme is inherited from Theme.AppCompat: <style name=”AlertDialogTheme” parent=”ThemeOverlay.AppCompat.Dialog.Alert”> <item name=”buttonBarNegativeButtonStyle”>@style/NegativeButtonStyle</item> <item name=”buttonBarPositiveButtonStyle”>@style/PositiveButtonStyle</item> </style> <style name=”NegativeButtonStyle” parent=”Widget.AppCompat.Button.ButtonBar.AlertDialog”> … Read more