I want to load different resource files according to Dark/Light theme in Jetpack Compose, but it is not working.
What should I do next?
Image(
modifier = Modifier.align(Alignment.CenterHorizontally),
painter = painterResource(id = R.drawable.ic_daynight),
contentDescription = null
)
res/drawable/ic_daynight.xml:
res/drawable-night/ic_daynight.xml:
Res folder:
theme.xml:
It is definitely possible in the way you've described - see my answer to a similar post here.
Maybe the difference here is that you're using an old Compose version? Make sure you're using version 1.0.1 or above for this to work as you expect. I assume you want this to take effect when you set your device in dark mode.
Related
I can't download imagine on small basic . After that, I install Visual Studio but it doesn't work.
Can anyone help me this problem:[enter image description here](https://i.stack.imgur.com/Nu2WU.png)
I want to download imagine on Small Basic.
the image can be previously loaded into an ImageList. Here you can see the size of the image and whether the download worked at all.
'Imagine = ImageList.LoadImage("https://aka.ms/mz1")
'...("https://social.msdn.microsoft.com/Forums/getfile/1353849")
Imagine1 = ImageList.LoadImage("http://litdev.co.uk/game_images/rubic.png")
Imagine2 = ImageList.LoadImage("http://smallbasic.com/drop/soko/sokocuteff.png")
TextWindow.WriteLine(ImageList.GetHeightOfImage(Imagine1))
TextWindow.WriteLine(ImageList.GetHeightOfImage(Imagine2))
TextWindow.WriteLine(ImageList.GetWidthOfImage(Imagine2))
GraphicsWindow.Height = ImageList.GetHeightOfImage(Imagine2)
GraphicsWindow.Width = ImageList.GetWidthOfImage(Imagine2)
GraphicsWindow.DrawImage(Imagine2,0,0)
GraphicsWindow.DrawImage(Imagine1,100,150)
GraphicsWindow.DrawImage(Imagine1,200,250)
It seems that only http: works and not https:
I using custom font for my Flutter app:
return MaterialApp (
theme: ThemeData(
fontFamily: "MyFont"
)
)
but in one place of application I need to use "system font". this is especially important for iOS (Sf Pro). If I understand correctly, this is the system font for iOS. But how can I use "system font" if I already use "custom font" at application level?
I tried:
final fontFamily = DefaultTextStyle.of(context).style!.fontFamily;
But this code return "MyFont".
also I tried importing from apple site. but there is only one big SF-Pro.ttf(8Mb) file inside the image. Not - SFPro-Regular.ttf, SFPro-SemiBold.ttf ... Flutter does not support .otf files.
How to solve this problem? any advice I will be grateful
Create an F# Xamarin Android project in Visual Studio 10.
The template contains a set of mipmap folders, to which you can add your own icons.
If I add the icon my_icon.png to each of the mipmap folders, then they should be picked up as a drawable resource: i.e. I should be able to use
type MyResources = MyProject.Resource
and then the compiler should pick up
let myIcon = MyResources.Drawable.my_icon
But it isn't.
Is this a bug? And is there a workaround?
The answer is laughably obvious.
The resource lives in MyResources.Mipmap:
let myIcon = MyResources.Mipmap.my_icon
Using Borland C++ Builder 2009 I notice that when replacing images in a TImagelist, the alpha channel data gets corrupted somehow.
TIcon *Icon = new TIcon() ;
for (int x = 0 ; x < OS_Specific_count ; x++)
{
OS_xx_ImageList->GetIcon(x, Icon) ;
Use_ImageList->ReplaceIcon(x, Icon) ;
}
delete Icon ;
The problem is also described (+screenhots) in another Q ( TImageList - True color + alpha channel vs. 8-bit (256 colors) ) but I'm now trying to narrow things down with more specific questions.
While browsing TIcon in the help file I noticed a read-only property: SupportsPartialTransparency.
It appears to be false in my case, and I wonder if this is not the key to solving this problem ? Icon->Transparent = true does not set SupportsPartialTransparency to true !
I wonder what I can do to make sure the TIcon instance correctly 'gets' and 'replaces' the alpha channel information ?
The ImageLists are created at design time and have default properties (nothing changed) and contain 16x16 icons imported via the IDE. The imported icons contain alpha channel information.
I just use TPngImageList, it is compatible with TImageList. Plus the design-time editor is more flexible: You will need to convert .ico to .png. .
It is free and widely available, for example here: https://github.com/TurboPack. No headache with transparency since :) BTW, keeping icons as PNGs is more suitable, you can use them on other development tools and platforms.
I have tried many different libraries, but none came.
None of them can not be specified without introducing his own style in Painter.
I need to be able to quickly and dynamically change the style tab.
In response, I showed my developments.
If someone has similar developments - write them in response.
I decided to upgrade the simplest of them: TJvTabBar of JVCL (latest revision: 13415)
Here is the result.
Before (default)
After
Style sources (All graphics imported from png files with transparency)
Easy apply any personal style to any JvTabBar
var tmp:TStrings;
begin
tmp:=TStringList.Create;
tmp.Values['TOP_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_background.png';
tmp.Values['TOP_active_left_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_left_side.png';
tmp.Values['TOP_active_right_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_right_side.png';
tmp.Values['TOP_active_center']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_center.png';
tmp.Values['BOTTOM_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_background.png';
tmp.Values['BOTTOM_active_left_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_left_side.png';
tmp.Values['BOTTOM_active_right_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_right_side.png';
tmp.Values['BOTTOM_active_center']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_center.png';
tmp.Values['CLOSEBUTTON_normal']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_normal.png';
tmp.Values['CLOSEBUTTON_selected']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_selected.png';
tmp.Values['CLOSEBUTTON_disabled']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_disabled.png';
tmp.Values['CLOSEBUTTON_closing']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_closing.png';
tmp.Values['CLOSEBUTTON_modified']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_modified.png';
tmp.Values['CLOSEBUTTON_closing_modified']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_closing_modified.png';
JvTabBar1.StyleImages:=tmp;
tmp.Values['BOTTOM_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\MYMOD_tabs-BOTTOM_background.png';
JvTabBar2.StyleImages:=tmp;
Main changes
Added ability to specify their own style ( JvTabBar1.StyleImages )
Added the ability to move the close button to the right ( JvTabBar1.CloseButtonRight: = true or false )
Many fixes to the size and position of text / icons / buttons / scroll
My JvTabBar.pas mod You can download it here http://pastebin.com/JmbufHy0
And example source style + JvTabBar.pas http://www.sendspace.com/file/shhuzr