Image recognised in Android Studio but invisible on Phone - android

My Images are being recognised like so (Look at the left):
However when I run the app on my phone the images just become invisible.
This just happened all of a sudden, I don't believe I changed anything other than copied other images into the folder, it seems like there is no consistency.
Also, I tried moving the icon images into the mipmap folders, specifically mdpi.
Still no luck. (So drawables and mipmap are broken?)
Any ideas?

Have you changed the theme recently?
If you have a white navigation bar but are using a dark theme, then the icons will show up white, regardless of the color you set them to.
So they are still there, but just the same color as the background.
Try changing the theme to a light theme.
If this works, but the rest of the app such as the Toolbar is not the correct color/theme, you can always override the theme for the Toolbar:
app:theme="#style/Dark.Overlay"

Related

Cannot resolve theme reference in Android Studio

I've recently added a light and darkmode theme to my android app, this works great in the app itself but in the design view on Android Studio, all elements like textviews, imageviews etc are all white and have this message: cannot resolve theme reference ?attr/textcustom
This goes for text, images, backgrounds. All with the same error
In this image you see all buttons, text etc are white. But when opening the app they get the correct colors etc.
Try changing the preview theme, the option is located right on top of the design panel:

How can i change icon.png depending on app theme (day/night) android kotlin

I have a logo on my splash screen and two files:
logo_night.png and logo_day.png
How can i change this logo that will change depending on the theme of the app using these two files?
The usual way is to use a night resource qualifier, so if you're using a dark theme it pulls the named resource from the equivalent night folder if it exists there.
You have three basic options with this I think:
just call them both logo.png, but put one version in drawable and the other in drawable-night. That way, whenever you refer to #drawable/logo it'll pull the correct version depending on the theme. If you have multiple density versions, in drawable-hdpi etc, you'll need them in drawable-night-hdpi etc. (the qualifier order matters)
if you're making your splash in the usual way, where you create a splash drawable with a background layer and your logo drawable on another layer, you could just make a night variant of this instead (in drawable-night). Each version can explicitly refer to logo_day or logo_night and you can just keep those PNGs in the normal drawable folder
or you can make a night version of your splash theme, and explicitly set the background to the dark version of your splash drawable instead. Both your splash drawables can stay in the normal drawable folder
So basically, something's gotta get a version in a night-qualified resource folder, so it can provide an alternative resource for dark mode. It's up to you which resource in that hierarchy you want to make the night version of (or you can do it for all of them if you want).
Also bear in mind that your splash theme (if you're doing it that way) follows the system's dark mode setting. If you're implementing a toggle in your app, and you set it to dark mode, the splash will still show up as the light variant if that's what the device is set to. That theme is set before your app starts and gets to work out if it should be in dark or light mode
Since you are using png format. You can call .getTheme() on context object to get current theme, make an if statement to decide which png to show.
For example in activity you can get theme by just calling getTheme() because this.getTheme() is implied.
Other possibility is to switch to vectors where you can define different colors for different themes they will change automatically when user changes theme. This is probably better and more scalable solution. You can find much more details here.

Android - How to change Default Loading Screen(Screenshot)? [duplicate]

The app itself works completely fine. My question is that on the launching of the app itself, the screen is the Unity default blue for a quick second or so before changing to the black of my first scene.
How do I change this color to be black on startup?
You can change this by going to File --> Build Settings --> Player Settings --> Splash Image --> Background --> Background Color.
From there you can change the background color. You can also change the image, animation type and overlay opacity from there.
Note that there are things you may not be able to change there unless you have Pro license.
EDIT:
Updated to be more detailed of where to change stuff
First change the Splash Image:
There are more options for iOS platform but this settings can still be found in the menu I mentioned above.
If iOS, select iOS as your platform and you can change your Background Color from there:
You should then change the Lunch Screen type from there. Set it to None if you want it to be gone.
If the color does not still change, you can create a Texture with a color of your choice and add it to the Mobile Splash Screen slot:
I believe the OP was looking for the Background Color of the Launch Screens as indicated in these screenshots.
This is taken from an iOS build setting panel. We've observed odd behavior with no textures at all (even though that is what we want), so we use single-pixel, solid-color images as well as a background color to match.
These fields are not made available in the PC/Android build windows, so not 100% sure what the equivalent would be - beyond using flat-colored images. Either way, it is these elements that are used prior to loading your scenes.
I think you are talking about the camera background color. You can set it up in your main camera to black. You can find the camera documentation here.

How to change icon colors in android studio

I downloaded some icons from material.io but they only offer the icons in black. I saw a youtube video where they use to allow you to choose the color. Anyway, I am trying to change the colors of the icons to white. I am not having any luck. I tried to change the fill color in android studio but it doesn't work. Any assistance would be appreciated such as exact code and files to add the code to. Thanks.
simply you can use
android:tint="#android:color/white"
You can directly download these images in Android Studio.
res > right click > New > Image Asset and select
Icon Type : Action Bar and Tab Icones
Asset Type : Clip Art
Theme : CUSTOM
And you can select any clip art that you want, select the color, padding, etc ...
As mentioned before, the material.io icons can be downloaded directly with Android Studio. This solution shows the importing of vector asset icons which are easier to manage since they are stored in a single location (res/drawable) vs. image assets that will have each icon stored in specific density folders (hdpi, xhdpi, etc).
expand the "res" folder
right click drawable
hover over "new"
select "Vector Asset"
click the image next to "icon"
select desired material.io icon
Name the icon what you would like
select "next"
Now you will have two options of setting the icon color
In the layout by using the android:tint attribute of an ImageView. This is my preference because the icon can be viewed prior to runtime.
or
In Java.
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
https://material.io/icons/ actually does let you download icons in white.
But, depending on what exactly you want to do, there are a few options. If you simply want white icons (and not to change them at runtime), you may find this plugin for Android Studio useful: https://github.com/konifar/android-material-design-icon-generator-plugin
It allows you to generate the material design icons right in Android Studio, in whatever color you want. Another alternative for downloading these icons in different colors is https://materialdesignicons.com/.
If you do want to color the icons at runtime, try something like this:
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
You can download white icons from material.io. also look at themes and theme overlays
Instead of android:src
I use attribute android:foreground
android:foreground="#drawable/ic_add"
For those not getting what they want yet try changing the PorterDuff mode, the following is what did it for me
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.SRC_ATOP);
maybe
app:iconTint help you, I am writing this because of the following reference.
Material Design 3

ActionBar dissapears when using sepcified resource folder

I am writing app with android:minSdkVersion="14". Everything went fine until I tryed to add support for tablets.
When I created values-sw600dp folder and copied there the default dimens.xml file from values folder and tried to run the app on tablet, it started behave differently even when those dimensions file were identical.
ActionBar was gone, getActionBar() started to return null, EditText fields are orange framed instead of that blue underline, whole app design now looks like its on android 2.0.
On smaller devices where it still used default values folder everything is ok.
For testing, I tried to lower the 600 threshold (in values-sw600dp) to 300 to force this folder to be used even on smaller devices and result was same. ActionBar gone etc...
Sorry for english and thank you for answer
Ok I found solution to my problem. I accidentally coppied line:
<style name="AppBaseTheme" parent="android:Theme.Light">
into my dimens.xml file in folder values-sw600dp, which caused application to use Theme.Light instead of my default theme Theme.Holo.Light.DarkActionBar in folder values-v14. I donĀ“t know how it got there but I am glad I found it.

Categories

Resources