When I'm using (Colors.amberAccent) in Flutter framework, the color square appears automatically. How can I show it in Android studio beside Lines number if I'm using Color.fromARGB(255, 100, 100, 23)?
The second question is, can I use this color style (#ff0000) in Flutter framework?
I've put an image to clear my idea.colors
String color = '#ff0000';
String hex = color.replaceAll("#", "");
Color col = Color(int.parse(hex, radix: 16)).withOpacity(1.0);
P.S. Or, you can use this
To answer your first question: It is not possible to display the color in the IDE when you use something else that Colors.colorName.
For your second question: you can use the style you described with this syntax Color(0xff5600). That will return a Color object instance
return new MaterialApp(
title: appTitle,
theme: new ThemeData(
primarySwatch: : Color(0xff5600),
),
home: ...
);
The color square will appear if you put the color as a constant:
Color color = const Color(0xFF536DFE);
Related
in before xml in TextView we have
holder.binding.iconInfo.text = "&#x${iconValue}"
and set out icon font to it with typeface dose anyone can help same thing but with jetpack compose
The specific syntax you mention that can be used with TextViews is due to the fact that XML is used when defining layouts. That is an XML numeric character entity that specifies a character with its unicode value in hexadecimal notation.
So it is not related to TextViews, layouts, fonts or icons.
If you want to do the same with a String in Kotlin and the character value is dynamic, you can do something like this
val text = "${Char(iconValue)}"
In Compose a custom font can be defined either as part of your Theme -> Typography and then used as text style or you can define it directly like this
val fontFamily = FontFamily(
// If you have the font in resources
Font(R.font.my_font_normal, weight = FontWeight.Normal),
Font(R.font.my_font_bold, weight = FontWeight.Bold),
Font(R.font.my_font_italic, weight = FontWeight.Normal, style = FontStyle.Italic),
// If you are loading the font at runtime from a file
Font(File(...), weight = FontWeight.Normal),
// ...
)
// Use with Text composable
Text(text = text, fontFamily = fontFamily)
I am trying to obfuscate some text with Jetpack Compose. Obviously, the blur modifier works wonders for this use case if you have Android 12.
My alternative for devices running a lower API version would be to simply draw a rectangle with a black colour over the text. I assumed this would be relatively easy with existing modifiers like graphicsLayer or drawBehind but I haven't been able to figure it out and I'm at a loss for ideas right now...
My current text composable looks like this:
Text(
modifier = if (blurText) {
Modifier.blur(16.dp, BlurredEdgeTreatment.Unbounded)
} else {
Modifier
},
text = textToObfuscate,
fontFamily = latoFontFamily,
fontWeight = FontWeight.W700,
fontSize = 16.sp,
color = black,
)
I could wrap the text in a Box and have another Box inside it to draw over the Text but that just seems useless and more work than should be necessary.
If anyone has any ideas on how to achieve this simply using a Modifier extension, that would be amazing!
You can use Modifier.drawWithContent as
Text(
modifier = if (blurText) {
Modifier.blur(16.dp, BlurredEdgeTreatment.Unbounded)
} else {
Modifier.drawWithContent {
drawContent()
drawRect(Color.Black)
}
},
text = "textToObfuscate",
fontWeight = FontWeight.W700,
fontSize = 16.sp,
)
I have a custom ViewCell with a StackLayout like this:
var viewLayout = new StackLayout () {
Padding = new Thickness (10, 0, 10, 0),
Orientation = StackOrientation.Horizontal,
Children = { nameLabel, button1, button2 }
};
When I use Xamarin.Forms standard ViewCells, i.e "TextCell", the label will get a blueish color on Android. My questions is: Where can I find this property? I want to set it to my custom nameLabel like this:
nameLabel.TextColor = TextCell.StandardTextColorForCurrentPlatform;
For TextCells:-
On Android you can get this value via Color.Accent.
On WindowsPhone use the system-defined PhoneForegroundBrush.
iOS appears to be hard coded to black.
You can write a simple DependencyService to return the appropriate color per the platform your executing on.
Title of this questions says everything. I only found out how to change the color of connectors. If I delete the color: option, they´re all grey. I tried to put in the field with stored colors in hex, with no result, stayed black.
In dataLabels.formatter you have access to this.point.color. So simple set useHTML: true for dataLabels, and create spans with specified colors.
the formatter function gives you a callback object, which has a color property that can be set with the color of your choice
formatter: (format) ->
format.color = #point.color
The ComboBox text color is white even though I've set it to black in my theme. The text color of TextField is black as supposed to. How come the ComboBox text color isn't black?
The theme:
fgColor=FFFFFF
bgColor=000000
sel#fgColor=FFFFFF
sel#bgColor=EE8207
ComboBox.fgColor=000000
ComboBox.bgColor=FFFFFF
ComboBox.sel#fgColor=000000
ComboBox.sel#bgColor=FFFFFF
TextField.fgColor=000000
TextField.bgColor=FFFFFF
TextField.sel#fgColor=000000
TextField.sel#bgColor=FFFFFF
You can change the text color like this
Style selStyle = UIManager.getInstance().getComponentSelectedStyle("ComboBoxItem");
selStyle.setFgColor(0x00AF00); // Selected Item will be in green color
UIManager.getInstance().setComponentSelectedStyle("ComboBoxItem", selStyle);
Style unSelStyle = UIManager.getInstance().getComponentStyle("ComboBoxItem");
unSelStyle.setFgColor(0x000000); // Selected Item will be in black color
UIManager.getInstance().setComponentStyle("ComboBoxItem", unSelStyle);
This will work out!!
You should use hexColors: "0x000000" or "0xffffff"
You can also set the color in your app using following methods.
lwuit uses int's to set a color, to calculate the int use the following function.
public static int colorStringToInt(String hexColor) {
int color;
try {
color = Integer.parseInt(hexColor.substring(2), 16);
return color;
} catch (Exception ex) {
ex.printStackTrace();
return -1;//no negative colors
}
}
set the color like this.
int color = AppUtils.colorStringToInt("0xffffff");//white
if (color != -1) {
b.getStyle().setFgColor(color, true);
}
you can use like this,
ComboBoxItem.fgColor=000000
ComboBoxItem.sel#fgColor=ffffff
Are you using ResourceEdit. If u r not using means use the ResourceEdit and create the theme.