androidstudioguide1

 

Let's break down Android Studio into some more manageable pieces

Project Folder - This where you can access all of your files.  This file structure is very rigid and should not be changed in anyway, just added on to if necesarry.  There are two top level folders here; App and Gradle Scripts.  The app folder contains one of your app's most important files, the manifest file, which contains essential information about your app that it gives to the operating system before any code in your app can be executed.  Then there are the java code files and the resource directory, which includes things like layout files, images, style rules and much more.

Palette - This is where you pick the tools, called Views, that you want to display on screen.  You can simply drag each View over to the Layout Screen to place them or down into the Component Tree.  The views are categorized by type with the more common ones at the top.  You will get familiar with this panel very quickly. 

Component Tree - This panel shows you how you app is laid out in a topological view.  You can expand each parent View to see the child Views it contains.  This is helpful as you get more views into your activity and it becomes difficult to select the right one on screen.  You can also drop Views from the Palette into the tree for more precise placement.

Layout Screen - This is where all that hard work you're putting in will show up.  Drag Views from the Palette into here to see what they will look like on a real device.  The controls at the top let you select if you want the blueprint to be displayed, whether you want portrait or landscape orientation, which API version you want to target, and the theme you want your app to use.

Properties - The Properties panel is perhaps the most important part of all of this.  Each View has certain characteristics that allow it to respond to user interaction and the Properties panel is how you as a developer control them.  Each View should have a unique ID so that it can be referenced through java code.  Along with this, each View has layout properties so that it appears in an attractive way.  It has the ability to call methods in your code in response to certain events, and much more.

What's that Res folder all about?

By default, a few of these folders are included in the res directory (marked with an *).  Often you will find that you need another resource but aren't sure where to put it.  Also, if you try and add a directory that is not names exactly like one of these following folders, it will not show up in your Project Folder.  When you need to add a new resource, right click on the 'res' directory and go to 'New' -> 'Android resource directory'.

androidstudio_openresdirecotry

Here is the list of folders you can add and what each of them should contain.

  • Anim - Also referred to as the tween animator.  This is used for scaling, rotating, translating, or changing the alpha on Views.  What sets this apart from the next folder is that these files don't actually animate the view, they just animate how the view is shown.  Say you have a wide, short button on screen and you animate it 360 degrees around.  As the user sees it rotating, the button itself is in that exact same position, so if you were to click it in its rotated state outside of it's original location, it would have no effect.  The button is not actually there.
  • Animator - This is for property animations, or animations that are not only for views, but any object.  This also animates the whole object, not just the drawing of it.  So if you animate a View with the property animator, the whole view is moved around screen.  It is not just drawn elsewhere.
  • Color - This folder is for providing state-lists of colors.  Many View's can have different operating states, that is, pressed vs not pressed, checked vs not checked, etc.  Based on the state of the View, you can change how it is drawn, or it's color perhaps.  That's what you keep in this folder.  For defining single colors, like red as #FF0000, store that in Values/Colors.xml.
  • Drawable - This folder is for storing either vector drawable files, images that can be scaled without losing resolution.  These are images that are described in Xml format instead of rgb data.  It's like instructions for building the image rather than the image itself.  This is my preferred method for storing images because it keeps total app size down but the images are harder to create.
  • Interpolator - This is for smoothing transitions and animations in your app.  It is not realistic looking to show linear movement on most objects so it is best to smooth in and out of the transition.  This gives a much more visually pleasing look to an app.
  • Layout - This is the folder that holds all of your Layout xml files, the files that describe the look of your Activities, Views, and Fragments. 
  • Menu - This holds the information for the toolbar menu's in your activities.  To set them, use the onCreateOptionsMenu() method and to respond to clicks, use the onOptionsItemSelected() method.
  • Mipmap - Mipmap is the term used to describe different levels of detail of an image.  This is commonly seen in video games.  When you are very far away from an object, say, a mountain, the mountain kind of just looks like a brownish/grayish triangle in the distance.  As you get closer to this mountain, more detail is revealed.  This is because a different, much less detailed mountain was drawn when you were further away from it.  It saves system resources to do things this way.  This is how images are saved in Android.  When you create an image, you should import five different resolutions of that image to accommodate various devices with different screen sizes and pixel densities. 
  • Raw - This is for any files that you can save in their raw form, although it is often used for sound files your app may need. 
  • Transition
  • Values - Strings, colors, dimensions, and other hard coded values that will be used throughout the app.  This is so that if you want to change one value, maybe change an error message if a user forgets to enter a piece of information on a form, you can easily find it right here instead of looking through pages and pages of xXml files for the right line.  Strings are also stored to provide easy ways to translate your app into multiple languages.
  • Xml - This is an odd name since all of these other folders can hold Xml files with the exception of Mipmap maybe.  I've found that when you create a settings Activity, files are automatically put into this folder.

Leave a Reply

Your email address will not be published. Required fields are marked *