I'm trying to figure out how to change the following image on start app with LibGdx framework.
I would like to customize it with my logo , but I can not find the reference in the solution .
Thanks for your help.
For IOS platform you should add in your ios/assets folder your own splash images in all resolutions with defined naming structure of Apple.
"Default.png" - 320x480 iphone3gs
"Default#2x.png" - 640x960 iphone4
"Default~ipad.png" - 768x1024 ipad
"Default#2x~ipad - 1536x2048 ipad retina
...etc
more details you can find here ..
Libgdx project for iOS displaying libgdx splash when compiling through robovm on simulator?
In windows explorer go to <path to your project>/desktop/assets
You'll see the default LibGDX image and here you can put all of your assets files (images, fonts, etc). You may also need to refresh your project folders in Android Studio so that the new image(s) will show up.
The java file that loads the image is under the core/src folder. Open this file and you will see where it loads the default image. Change the name of the image to the name of your new image and that should do it.
NOTE: If you are planning to build for android also, android will only see assets that are located in the android/assets folder (it's annoying, but this is the only way it works). I don't use Android Studio, but look up how to set the working directory for your desktop project to use the android/assets folder (instead of desktop/assets). Then put all of your images into the android/assets folder. This one took me a while to find out when I first started building for android. So if your desktop build works, but android doesn't...this is what you need to do to fix it. :)
1)for android, go to asset folder and paste your image
2)Refresh the asset folder
3) in your create method
//libgdx.png is the default image name that provided by the libgdx
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
//in above code remove that "libgdx.png " and add your image name
Example:-
texture = new Texture(Gdx.files.internal("your image name.png"));
Related
When I try to programatically set custom font from .ttf file in assets to button in my android app it returns error Caused by: java.lang.RuntimeException: Font asset not found fonts/menubutton.ttf.
Assets folder is in main directory, and I use this code:
Typeface tpf = Typeface.createFromAsset(this.getAssets(), "fonts/menubutton.ttf");
benterday.setTypeface(tpf);
How can I repair this error?
There is a new way to accomplish this:
put your_font.tff under app/src/main/res/font
create Typefaces using Typeface font = ResourcesCompat.getFont(context, R.font.your_font);
access font from xml layouts with android:fontFamily="#font/your_font"
source
This could be due to a number of issues. Please see which one works!
The font file is corrupted. Please see whether the app works with another standard ttf font.
Sometimes Android Build studio shows up bugs. Try cleaning the project and building again.
Verify the font folder and the font file name (no spaces etc.)
There is 2 ways to add fonts in android studio.
first way: right click on you app folder and choose:
app->New->Folder->Assets Folder
then in newly created folder right click and then selected "New->Directory" and set the name to "fonts".
now you can add your fonts here and your problem would be fixed.
second way is #andreaciri way that works in newer versions of android studio.
I want to add my app Icon to created folder instead of default folder icon.
I know i can create folder with following code.
String extr = Environment.getExternalStorageDirectory().toString();
File mFolder = new File(extr + "/My Application/Downloads");
if (!mFolder.exists()) {
mFolder.mkdirs();
}
By doing this, i'm getting following result.
but what i want is..
I have searched a lot, but no luck. can anyone help me out?
Thank you.
Directories do not have icons, and so whatever app or tool your screenshot is from is adding that. You would have to ask the developers of that app or tool what algorithm they are using to determine the icon to show.
Customization of folder icon is OS dependent.
On Windows you will use Desktop.ini file to assign a custom icon or thumbnail image to a folder. To simplify working with Desktop.ini you can use ini4j. Basically, you will need to create Desktop.ini in the folder, that you want to customize and specify path to the icon there. (Here is similar question)
On Mac OS the process is different. There are ways to access icons (for example, FileView or FileSystemView, also Quaqua). However I haven't found a way to set folder icon programmatically with Java.
Note: I assumed, that you want to add icon to arbitrary folder and not your app laucher.
After creating new directory you have to declare resource directory in your gradle file so that android studio can recognize new resource directory.
More information please refer https://developer.android.com/studio/write/add-resources
I'm using eclipse, and my app is at a point where there is a background, and when I run the emulator it doesn't have the background. It had done this before where I changed some text, but when I ran the emulator the text stayed the same. If someone could tell me what I am doing wrong then that would be great. Thanks.
I have noticed that changes made to xml files sometimes do not show up unless you do Project > Clean...
i tried the layout it works fine. You create a folder named as drawable similar to drawable-hdpi. Put your image inside the drawable folder. It work fine.
or
Blockquote
Another option about the problem is that you created you Emulator in such a way that the Android OS determines its screen as xhdpi. If an image is placed in drawable resource folder then Android will try to rescale it for the different resolutions. However if the image appears only in some of the resolution folders (lie drawable-ldpi etc) then the image will be served only in this resolutions.
Please, either create folder drawable-xhdpi and place the image also there, or create folder drawable and place the image there. It will be used for backup.
See the documentation about the image folders: http://developer.android.com/guide/practices/screens_support.html
This is a stupid question, so I'm sorry if it's been asked before but I cannot find the answer and I'm not even sure if it matters or not, but:
If I want to add Icons to my Android app, not just the App icon, but other icons and graphics. Which folder do I place them in, or how should I add them? I am using Android Studio to create my Android app and I know that the App's main icons (Launcher icons) are located in res/drawable-x but is this where I also put other graphics and icons too? I looked in the documentation and searched SO and Google but only found answers relating to App Launcher Icons.
You put all the icons and images res/drawable-xxx folders, e.g.:
/res/drawable-mdpi - resources for medium pixel density
/res/drawable-hdpi - resources for high pixel density
/res/drawable-port - resources just for portrait mode
More info here: Providing Resources
Got to
Project name --> res/drawable and paste all your icons
Yes res/drawable-x is where you have to add the images
The main folder is drawable but if you want app to support multiple density you can create multiple drawbles for different dpi and paste them to relative drawable folder
The hierarcy goes like this
res/
drawable/
icon.png
background.png
drawable-hdpi/
icon.png
background.png
there are more type of folders
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi // Added in API Level 8
drawable-nodpi
drawable-tvdpi // introduced in API 13
and also different drawable for different orientation you can add
drawable-land
drawable-port
Learn more here
provide alternative resources
In my drawable folders i have my icon image, and when testing i use it as a temp picture. I added 2 other images and a XML file and when ever the app loads the imageviews with the icon set to it has different images..
this is what it is meant to be be..
but this is what it is when i add other images to the drawable folder
And no, the names of the files are not the same.
The icon is called 'icon.png' - thats what it should be
instead it is 'ic_menu_compose.png' - a completely different name.
Also the files i'm adding are called:
'buttonnormal.png'
'buttonclicked.png'
and a XML file - 'buttonselector.xml'
Even if i dont use these images any where within my app the problem still occurs.
Any help would be much appreciated. Thanks! :)
[EDIT]
Are you building your app inbetween tests?
In eclipse: Project > Build Automatically (ticked) (this regenerates your R file)
Are you referencing the image by a raw ID?
setImageResource(324234234); WRONG
setImageResource(R.drawable.blah); Right
Are you using drawable image names that are already in use by the Android system: http://androiddrawableexplorer.appspot.com/
Personally I would rename that images from "ic_menu_compose" to something like "icon_menu_compose_overwritten" just incase it is clashing and screwing up your R file.