Description: if we need to scroll two ScrollLayouts at the same time we can create a new View that implements the standard ScrollView in order to create a listener which allow us to know when this one is scrolling and modify the behavior of the other (or maybe because we want to know about the scroll behavior).
Code:
IScrollListener.java
1 2 3 4 5 6 7
publicinterface IScrollListener {
void onScrollChanged(
IScrollListener scrollView, int x, int y, int oldx, int oldy);
@Override protectedvoid onScrollChanged(int x, int y, int oldx, int oldy){ super.onScrollChanged(x, y, oldx, oldy); if(listener !=null){
listener.onScrollChanged(this, x, y, oldx, oldy); } } }
Use two ObservableScrollView in your layout: oScrollViewOne, oScrollViewTwo.
Description: We can drop shadows to our controls (TextView, Buttons, Checkbox, …). Adding this shadow, we can create a better interface in our applications (but be careful adding shadow to everything!).
Description: We can create nice buttons simply using few colors and gradients. We need to create a Selector resource and attach all the shape items for every state: pressed, focussed, disabled and normal. In the most common cases, focussed and normal could show the same result. In the case of pressed and normal, we will invert the colors. And in the case of disabled, we will use other colors (like a gray color).
<!-- ... --> <!-- Better if you use most of the attributes in a style --> <Button android:id="@+id/btnStart" android:layout_width="fill_parent" android:layout_height="40dp" android:layout_margin="3dp" android:gravity="center"
A year ago, I started programming with XNA and I decided to build some game examples. One idea was create a clone of the videogame PixelJunk Monster but with some differences: the stages, chips, characters, monsters, paths and behavior could be totally customizable. For that propose, I did a Stage Tool application too.
The project is not released because it needs music, effect, better graphics (and maybe fix bugs too), and so on. But here, some captures and the main screen song.
On middle/big projects we usually add lots of resources that we can use on code files, layouts or other resources. When we start to do modifications to the project, sometimes we forgot to remove unused strings, drawables, layouts and so on.
I wanted to create a script to check these unused resources on our Android project, but I found a project which already does this task. This project is called android-unused-resources (good name to google it), and we can download it from:
When we are creating a multi-language application for Android, we need to create several folders to save the strings of different languages (see Android tip #014 – Multi-language application). When we are handling hundred or thousand of strings, we can forget adding a string in all language files.
Looking for a tool to organize all the strings in my project and check if any string was missing, I found the W.F.M.H’s blog were you can download a PHP script to help you for checking all your strings.
Missing in<LANG>(You need to add these to your file)
File: values-es/strings.xml ------------------------------------------------------
header_title
description_label
Missing in EN (you probably shall remove it from your <LANG>file)
File: values/strings.xml ------------------------------------------------------------------
mysection_label
Summary ----------------
BASE file: 'values/strings.xml'
LANG file: 'values-de/strings.xml' 2 missing stringsin your LANG file. 1 obsolete stringsin your LANG file.
Description: if we have a service in background and we need to launch an Activity in foreground, we need to add the tag FLAG_ACTIVITY_NEW_TASK to the Intent.
Description: two operations are expensive when we create custom lists: Inflate (covered on the tip 23) and findByViewId(int). We can avoid call to this second operation saving the views used for every row in a wrapper.
This pattern implies use a Model and a Wrapper. The Model will save the information of every row and the Wrapper will save the Views. We need to save the wrapper in every row view using the properties getTag() and setTag(Object).
This example will use only one value in the model and a TextView in the wrapper, but you can extend it as much as you wish.
Description: we can optimize the Adapters attached to a ListView inflating our custom layouts when it is necessary. This process is easy to implement with only one condition (Android will managed the rest of the work).
I am Miguel, a Spanish guy who loves computer science. Actually, I like a little bit of every field: security, networks, mobiles, algorithm, and so on. When I finish my first career and my first master read more...