I have a very simple application that runs an html file. I really want to change the color of the status bar, because the standard top and bottom in black is horrible for the color palette of the page shown. I have no idea about Android and I can't start learning now, but I tried to follow the answers, as in this question here at Stack Overflow: How to change the status bar color in android. However, I can't even find the styles.xml file that is indicated to put the parameters inside. I tried to create the "value" folder with the styles.xml file inside, but it only corrupted the app, as I imagined it would happen.
This is how the file tree of my app (generated by the Website to APK Builder) is seen:
What do I do to accomplish this? Please help me!
Note: I tried the edits through Android Studio.
For more details, here's the .apk: Google Drive
Change project structure to Android.
Follow below image
Now getting structure like below Image:
Here is style.xml file present under res->values
If not getting style.xml file, then Create new file res->values->New->Value Resource file
I hope this helps you
No need styles.xml file in the new Android Studio. Goto your project file view: Res>Values>Themes folder.
Open themes.xml file change actionbar.
android studio live example
You can find it in your resource directory
res/values/styles.xml
Right click on res - new - package - write the name of package as values - in the drop down of folder type, select values - ok.
The values folder is created!
Right click on values package - new - Android Resource Xml file - write name as styles in the name section - Ok.
Related
Android studio beginner here. My professor is telling me to change the res/values/strings.xml in my application. The purpose of this is to add a Color definition to the file and then tells me to press an "Add" button. However, I'm having trouble actually accessing the same window he is...here is the window:
What I see when opening the strings.xml file is this:
There are no buttons for me to actually add a definition. I tried playing around with the strings.xml file by right clicking the file, but nothing really looks like anything I want.
Any help is appreciated!
My professor is telling me to change the res/values/strings.xml in my application.
Here you mention that you want to change the strings using Add button. In that case, you can do it as follows:
Click on Open Editor on the top right when your strings.xml is open.
Then you will see this new Window. Use + key to add a new string resource.
Your professor might have a different Android Studio version. This is how it shows in Android Studio 2.3.3 version.
The purpose of this is to add a Color definition to the file ...
Here you mention that you want to change the color definitions. If that's the case, you need to change in colors.xml. If a file is not there, then create one in values folder and add <color name="color_name">#HEX_VALUE</color>. Then you can reference the color from Java or XML file.
Just add another entry in your strings.xml file corresponding to what your requirement is, and save the file.
For example:
<resources>
<string name="app_name">Temperature Converter</string>
<string name="new_string_name">new_string_value</string>
</resources>
Can some one in explain me in layman perspective how to use Android Holo Colors Generator
If I generate app theme name as AppTheme_Test and then putting all the res folder and then mentioning in manifest like android:theme="#style/AppTheme_Test" > It is not working, ie not taking color effect of Button, though I selected the button color in the generator. How to use it ?
At website link I have posted there is an option Download ZIP..HIT it..
Extract it where you want.
Extracted file contains res folder, copy and replace res folder in your project (I recommend to merge style file with present file).
Define element in layout file with background from drawable folder..
It will reflect your holo generated ..
In Android Studio, I want to create the folders values-v14 values-v21 inside the res folder.
But when I tried to make it like: right click on res folder select option New >Directory, then after creating the folder, it is not visible in Android Studio. But when I select the option Show in Explorer, then it is visible.
How do I create a folder in Android Studio, so that I can change files like styles.xml, etc?
Try to switch from Android to Project as shown below
Switching from the Android view to the Project view will allow you to see the directory structure, but it is less convenient for viewing and editing Android files.
There is a better way. Don't use New > Directory.
Right click values and choose New > Values resource file.
Select Version from the list and click the >> button. Write styles as the file name and 14 as the version number and click ok. (Repeat all this for version 21.)
Android Studio will automatically create values-v14 and values-v21 directories with the new styles.xml files in them. And in your Android project view you conveniently see all three styles.xml files together.
Other directories and resource files can be similarly added.
Layout files
Language translations
You can also manage language stuff with the editor, it´s a little faster.
Instead to looking for the file from ANDROID, go to PROJECT and then look for the folder, you will find it there...
I believe this is like version control, where the folder exists, but you need a file inside in order to view it. I just ran into this, and the folders existed but didn't show up until I had a file inside of them.
I hate to think this is by design. The use-case of a developer hiding their own work-space? Collapsing makes more sense
it's so simple to find your new values-v21 or recently created..
(1) - Go to project files
(2) - app > src > main > res
(3) - if here is not visible your directory then
(4) - right click on res and select show in explorer
(5) - Go inside res here all your files are shows
(6) - Then Go inside values > copy style file from there and come back to paste inside your values-v21 folder
(7) - you are done .. go to your android studio and see your folder values-v21 is appearing.
Note :- Your folder was empty so you folder was not appear in android studio.
I am trying to create a new folder inside the /res directory
I added a new directory
The folder does not appear in the /res folder even though it exists in the finder
Case and point I tried adding the folder again and I got a message telling me it exists.
If you can suggest what I can do to fix this I'd love it!
(And yes I have restarted the program as well as my computer)
Turns out there is a selector at the top which, by default, is set to show Android. If you flick the toggle down to 'Packages' you can see your own packages.
In Android Studio you can add new directories by right clicking the resource folder in the Android view. (Don't get confused by the New Directory option.)
For example, if you want a new layout resource file and folder then right click layout and choose New > Layout resource file.
If you want a new layout-sw600dp for the activity_main.xml file then choose Smallest Screen Width from the list and click the >> button. Fill in the file name and width and click ok.
Android Studio will automatically create the layout-sw600dp directory and in the Android view you will have both layout files conveniently displayed next to each other.
It is a similar process for adding other resource directories and files (see my other example).
Clicking at TAB Android in top, select the perspective Project Files. Then u can see all folders of project.
Android 4.0
The Android view by default seems to conceal the duplicated resource type directories in the side panel.
If you want to view the duplicate resource type directories i.e. drawable for two different languages,
switch the view from "Android" to "Packages" or "Project" or "Project Files"
Browse the actual folder structure in windows and you'll see the folder. Put the same resource file found in the normal drawable folder into this new directory. Then when you go back into Android Studio you'll now see 2 files under the NORMAL \res\drawable structure. Make sure you don't look for a subfolder in Android Studio called "drawable-sw600dp" because you won't find it other than in windows explorer. What you will find in Android Studio (after you copy the resource file) is a new resource file along with your original called "jenny-web.png (sw600dp)" or something similar. This same principle resolves the same error when working with other resources like layouts.
For Android Studio 3.0, those who are following https://developer.android.com/training/basics/supporting-devices/languages.html and have encountered the same issue as the one stated in this question, you can also do the following aside from the above answers which are helpful.
Right click to the target folder (i.e. res folder) > New
Choose Android Resource File
Specify the file name, and in the Directory name field put the folder name you want to create or the existing folder you want to put the resource file.
After hitting OK, in the Project files dropdown, you will see the correct strucutre.
And in the Android dropdown, you will see it as part of the strings.xml under values folder.
This worked best for me. What I did was I right-clicked the 'app' directory and chose 'New' >> 'Android Resource File'. After that I filled in the File Name with 'strings'. Chose 'XML' as my resource type and my Directory Name was 'values-b+za+ZA'.
This created everything as I wanted it to, however, values-b+za+ZA, still didn't show in the Android view but it shows in the Package view. (The views you choose from the top dropdown.)
The difference this time is that in the Package view I can still see my new 'strings.xml' file and in the Android view I van also see the new 'strings.xml' file.
I guess android studio doesn't show custom directories in the Android view but creates like some kind of link to the true directory when working with it. I am not familiar with Android Studio at all but this did work for me. If there are more professional answers please feel free to correct me.
You most probably have the file named in Uppercase, Android Studio does not recognize file names in Uppercase, I had made this mistake a while back.
As the developer doc states:
be sure the Project window is open (select View > Tool Windows > Project)
and the Android view is selected from the drop-down list at the top of that window.
You will then be able to see all relevant project files (including new ones) in a more efficient way.
Hope it helps someone.
This is odd but in my case i had to many underscores delimiters.
When i renamed yt_search_view (2 delimiters) to yt_searchview (1 delimiter), it appear in project view where it should be. It is probably a bug. My version is Android Studio 3.2.
Also, i notice that if i add a value folder to the layout folder, it also fix the issue.
Example:
layout_control_x
--layout
----top_panel.xml
--values <--adding this empty folder fixed the problem
For complete information on how to add sub folder layouts check this.
I am new to Android Development. I was just following the basic turorial on developer.android.com to create my first application.
As I was creating the Action BAr, I had to add this Search button to it. I created the menu xml and this is what I had written on it.
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
Now my question is on this part of the XML
android:icon="#drawable/ic_action_search"
I get a compilation error in eclipse, which says,
error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_action_search').
I checked on developer.android.com and also googled it out, but I'm just not able to locate a solution.
I need to solve this problem. As always, I am able to skip this part of the XML and what I get is just plain text "SEARCH", but the icon will definitely look better.
Here is the easy way if you're using Eclipse:
Ctrl+N (emacs keybindings) to open the file wizard
'File | New | Image Asset' in Android Studio
Select Android, "Android Icon Set"
Edit name ic_action_xx, click Next
Clipart, choose the icon you want
Select theme (Holo Light means a light background, Holo Dark means a dark background)
Eclipse will automatically populate the res/drawable-* directories with the new icon, scaled to the directory size. No need to download anything, understand PNG or copy the icon into multiple directories.
I use the file wizard A LOT.
In Android studio:
Right click the Drawable folder > Select New > Image Asset
(Alternatively, click shift, shift and type 'Image Asset")
In the dialog which popped up click 'OK'
From the wizard you can customise the asset you require.
Choose if it's a Notification icon, Action bar icon or launcher icon. You can select icons from clipart, create icon from text or import an image from disk.
The wizard will take care of creating different resolutions for your new image.
You need an image called ic_action_search.png or ic_action_search.gif, for example. Paste this image in every res/drawable folder.
As others have advised, you need to have (put) the icon graphic, "ic_action_search.png" in the correct folder, which is "/res/drawable" You may have to move a graphic file for one or more of the "drawable" subfolders of "/res"
You can find the icon graphics (and others that you will, presumably, need in the future) at, (http://developer.android.com/design/downloads/index.html#action-bar-icon-pack)
Please note: do not use the "Core Icons/unstyled," in the package. Use the "All_Icons/holo_light," (most likely) or "All_icons/holo_dark."
The error means that you don't have an image called ic_action_search in your drawable folder.
You can download an image for search from Android Asset Studio if you like.
I suppose you copy pasted some example code, as other answers says you missed putting drawable into your resources. For testing you might use default android search icon:
android:icon="#android:drawable/ic_menu_search"
I am not sure if it is safe to use it in release apps
First think English is no my main language, i apologize for my typing. Ok let's go to the problem. All this works for me, i hope it works for you. I was following the same instructions from developer.android.com as you, and it didn't say that you have
to put it in both .xml, or i didn't see.
Because is too much stuff and is overwhelming, i know at first but i hope to get used to it soon. Under the folder: res/menu you have two.xml archive one for the main page and the other for the activity. What do you have to do is copy that you wrote to both .xml archive:
Display_message.xml
main.xml
remember the action bar goes along the way with the activity, as many as you have. That means if you add another activity, you have to paste this in the new one in order to void that error. By the way you already have the images int he their respective folder. if not, it going to pop the error again. I hope this was understandable and with sense.
An other way to add a new icon into your project in Android Studio (same as dturvene's in Eclipse)
1. Choose drawable directory; Alt + Insert or File/New...
2. Choose "Image Asset"
3. Select drawable\hdpi as your icon's destination
4. An option window will pop up. Select directory to your icon saved in your PC.
I just found the way to do it so I hope it help.