So, I'm developing an application in android studio, my company will give me designs created in sketch/illustrator, so how do I use them? Do I have to create the whole design in xml from scratch following the mock-up screens or can I get those mock-ups in .xml file and import them directly smh?
You need to create the XML file from scratch. When you get your designs the first thing you need to do is upload it to your Android Studio project. You do that by adding it to the 'drawable' folder. If you have more then one resolution (aka hdpi, xhdpi, xxhdpi and xxxhdpi) you have 'drawable-hdpi' folder (and so on).
After the designs are in your project, you need to implement them in your XML file.
You can do it for example with ImageView:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/YOUR-DESIGN"/>
So with the advent of Invision Studios, you can use your sketch app with a sketch app plugin called Craft which enables you to move your screens design to envision for prototyping and also to be able to view assets. Once you're on Invision, you can use the inspect tab to view some code snippets ranging from XML to Sass and even Css, which can be copied from clipboard. Description of how Invision studio looks
Related
I have recently started creating an Android application using Appcelerator's Titanium.
Since in the application I requires to keep several images/icons with different sizes & dimensions essentially, So I need some advice on how I should organize them in the project.
And as you know like in Android project (Android studio or Eclipse with Android SDK) there is a predefined folder structure so if you want to keep any image then put them in all device sizes corresponding to the prescribed folders. So based on device sizes it will automatically detect corresponding dimension image from device preferable folder.
So does same approach can we achieve in Appcelerator's Titanium ?
Below is the default project structure for Appcelerator's Titanium project (5.1.2.GA)
As you can see there is 2 places where I can keep images. So can you suggest me where I can keep my images and how can I access them
Thanks, Any suggestion will be helpful for me. ~Chandan
Titanium supports platform, device and density specific images via folder and file conventions. I won't go into details here, but these two links walk you through:
How to use Device Specific Images
How to use Density Specific Images
The first part is used to be more specific about when these resources should be used. Images in sub-directories give us more control over when they are used.For example images that are in a folder named "res-long-land-hdpi" will be used for:
Long screens, such as WQVGA, WVGA, FWVGA
Device is in landscape orientation (horizontal)
High-density screens; approximately 240dpi.
Documentation Link
for me i deleted all folders in android/images (First) and i replaced them by folders in android/res (second)
like this
I've been trying to create an image button to use in my test app. Once I've imported the asset it looks grainy and pixelated, especially compared to the app_compat radio button. Here is the comparison (custom asset on left).
How can I get the edges of my custom asset to be as clean as the radio button?
You need to provide assets for various screen densities. If your app is not providing such assets directly, then Android will try to make such by usually scalling what your app provides. This usually ends with pixelated graphics. Please read this article about how all this work in Android: https://developer.android.com/guide/practices/screens_support.html
Previously I made some apps with Adobe Flash Builder. That's works great but is not the best choice is some cases so I start with developing Android apps with use of ADT.
Like in Flash Builder you can set several icons for different screen resolutions. I can understand why but found it is not really necessary when creating one high resolution icon, this works fine (scaling down is better than scaling up). This also avoid the extra work that is needed to create these icons, just one icon.
Long story short, I want to create just one icon, 144x144 pixels at 96dpi and tell Android to use this icon.
Also I want to point the application icon to the asset directory instead of the res/drawable directory. The reason for this is that the icon can be reused by the (web-)application and for another reason, I have made a webApp tool to create a compressed version of a webApp and put the contents in the asset directory of a Android project.
Because the webApp can also run in the browser I have already created some icons (like favicon, apple-touch-icon and apple-touch-startup-image) and want to reuse these icons in the Android project automaticly.
The idea is also to create an application project template so it is quite easy to create a android app of a webApp.
Question
Andy idea how to change the location of for example the application icon? Using a path doesn't work (it generates an error, can't compile).
android:icon="#drawable/ic_launcher"
android:icon="assets/appicon.png" #<- doesn't work
Actually found the solution myself and is pretty simple. The only thing that is a bit tricky in ADT to validate the new declaration because at first 'it says' that the declaration is invalid. The workaround is to cut (ctrl+X) the declaration, do a project clean by Project|Clean and then put it back by paste it again (ctrl+V). Weird but true ;-)
You can declare a string resource like this (in XML file):
<resources>
<string name="app_icon">assets/appicon.png</string>
</resources>
android:icon="#string/app_icon" <- this works
Then you can use just one high-res icon image as icon for all devices! Looks great! See also picture below (between red rectangle ;-)):
I am new to Android but not to Java. Is there already a little framework which allows me to create layouts, custom views and drawables programmatically using CSS sheets for padding, borders etc; just like Nimbus/Three20 for iOS ?
We've working on an "App-Studio" so all the views, lists etc. are rather dynamic, basing on the CSS the user created by a visual style template editor.
And if not, would you recommend to create such Android layout xml files on the fly and then load them from file, or is it better to create the drawables by hand ? We'can't bake such files just into the build because the user needs to be able to change the style in real-time on the device.
Thank you.
Partial ans only to:
And if not, would you recommend to create such Android layout xml files on the flyand then
load them from file, or is it better to create the drawables by hand ?
I dont think you can create layout xml files on the fly and load them in the running app. They have to be created prior to compilation of the app.
Android uses Styles and Themes. Reading about these will help you generate some common patterns which you can use in your context. Once you have some patterns you can create these xmls using some automation tool prior to compilation (and avoid writing them by hand...:), funny computer changed the definition of by hand).
I'm newer in android development. And after using eclipse about 1 month... i hate this. I've setup NetBeans IDE for android development. It's fast, it's looks like cool and i like it. But have one trouble. I cant find how to use drawable resources (just like R.drawable.icon) :( . Can anyone help me?
PS: sry 4 my english
Use the file browser on the left hand side in NetBeans to open
YourProjectName -> res -> drawable and you will find your drawable files here. Also, Android provides different drawable folders to support multiple screen sizes, i.e : drawable-hdpi, drawable-xhdpi, drawable-mdpi. These are great if you wish to support your app on multiple screen sizes and don't want to scale the images using code (it makes them look ugly). Then you can just place different sizes of the same drawable image in these folders and android will automatically figure out which one to use!
Your English is quite decent in comparison to some of the drivel people post here.
This is simpler with updated version of NBAndroid (including NBAndroid Extensions). See some comments at http://www.nbandroid.org/2013/04/tuning-hyperlink-navigation.html