UnAngelo blog

…se io fossi un angelo
Subscribe

Thinking Like a Web Designer

September 13, 2011 By: Tim Bray Category: 1

[This post is by Roman Nurik, who is passionate about icons, with input from me and a bunch of the Framework engineers. —Tim Bray]

The number of people working on mobile apps, and specifically Android, is growing fast. Since modern mobile software-development is a relatively new profession, the community is growing by sucking in experts from related domains, one being web design and development.

It turns out that familiarity with web UI development, particularly using modern HTML5 techniques, can be a great primer for Android UI development. The Android framework and SDK have many analogues to tools and techniques in the Web repertoire of HTML, CSS, and JavaScript.

In this blog post, we’ll walk through a few web development features and look for matches in the world of Android UI development.

Device resolutions and physical sizes

One of the most important aspects of both Android UI design and web design is support for multiple screen resolutions and physical sizes. Just as your web app needs to work on any physical display and inside any size browser window, your native app needs to run on a variety of form factors, ranging from 2.5” phones to 10” tablets to (possibly) 50” TVs.

Let’s look at some ways in which CSS and Android allow for flexible and adaptive layouts.

Providing custom layouts for different resolutions

CSS3 media queries allow developers to include additional stylesheets to target different viewport and screen configurations. For example, developers can provide additional style rules or override existing styles for mobile devices. Although the markup (layout hierarchy) remains the same, CSS3 has several sophisticated techniques for completely transforming the placement of elements with different stylesheets.

Android has long offered a similar mechanism in resource directory qualifiers. This extends to many different types of resources (layouts, images or ‘drawables’, styles, dimensions, etc). Thus you can customize the view hierarchy as well as styling depending on device form factor, A base set of layouts for handsets can be extended for tablets by placing additional layouts in res/layout-xlarge or res/layout-sw600dp (smallest width 600 density-independent pixels) directories. Note that the latter syntax requires Android 3.2 or later.

Below is a CSS3 example of how one could hide a ‘left pane’ on smaller devices and show it on screens at least 600 pixels wide:

#leftPane {
  display: none;
}

@media screen and (min-device-width:600px) {
  #leftPane {
    display: block;
  }
}

The same could be accomplished on Android using multiple layout directories:

res/layout/foo.xml:

<FrameLayout>
  <!-- a single pane -->
  <View android:id="main_pane">
</FrameLayout>

res/layout-sw600dp/foo.xml:

<LinearLayout android:orientation="horizontal">
  <!-- two panes -->
  <View android:id="left_pane">
  <View android:id="main_pane">
</LinearLayout>

As a side note, if you plan on creating multi-pane layouts, consider using fragments, which help break up your screens into modular chunks of both layout and code.

There are also other neat ways of using resource directory qualifiers. For example, you could create values/dimens.xml and values-sw600dp/dimens.xml files specifying different font sizes for body text, and reference those values in your layouts by setting android:textSize="@dimen/my_body_text_size". The same could be done for margins, line spacing, or other dimensions to help manage whitespace on larger devices.

‘Holy grail’ layouts

Web developers have long dreamt of an easy way to build a ‘holy grail’ 5-pane layout (header/footer + 3 vertical columns). There are a variety of pre-CSS3 tricks including position:fixed, float:left, negative margins, and so on, to build such layouts but CSS3 introduced the flexible box module, which simplifies this tremendously.

Figure: An archetypal “holy grail” layout

It turns out that grail is pretty holy for Android tablet apps, too, and in particular for tablets held sideways in landscape mode. A good approach involves the use of LinearLayout, one of the simplest and most popular of the Android layouts.

LinearLayout has this neat way to stretch its children to fit the remaining space, or to distribute available space to certain children, using the android:layout_weight attribute. If a LinearLayout has two children with a fixed size, and another child with a nonzero layout_weight, that other child view will stretch to fill the remaining available space. For more on layout_weight and other ways to make layouts more efficient (like switching from nested LinearLayouts to RelativeLayout), check out Layout Tricks: Creating Efficient Layouts.

Let’s take a look at some example code for implementing such a ‘holy grail’ layout on Android and on the web:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!-- top pane -->
    <View android:id="@+id/top_pane"
        android:layout_width="match_parent"
        android:layout_height="50dp" />

    <LinearLayout android:id="@+id/middle_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <!-- left pane -->
        <View id="@+id/left_pane"
            android:layout_width="300dp"
            android:layout_height="match_parent" />

        <!-- center pane -->
        <View id="@+id/center_pane"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <!-- right pane -->
        <View id="@+id/right_pane"
            android:layout_width="300dp"
            android:layout_height="match_parent" />

    </LinearLayout>

    <!-- bottom pane -->
    <View android:id="@+id/bottom_pane"
        android:layout_width="match_parent"
        android:layout_height="50dp" />

</LinearLayout>

Note: Android tablet apps in landscape will generally show an action bar as the top pane and will usually have neither a right nor bottom pane. Also note that the action bar layout is automatically provided by the framework as of Android 3.0, and thus you don’t need to worry about positioning it.

And here’s an example implementation using the CSS3 flexible box model; notice the similarities:

<style>
  html, body { margin: 0; height: 100%; }

  #container {
    height: 100%;
    display: -webkit-box; /* like LinearLayout */
    display:    -moz-box;
    -webkit-box-orient: vertical; /* like android:orientation */
       -moz-box-orient: vertical;
  }

  #top, #bottom { height: 50px; }

  #middle {
    -webkit-box-flex: 1; /* like android:layout_weight */
       -moz-box-flex: 1;
    display: -webkit-box;
    -webkit-box-orient: horizontal;
       -moz-box-orient: horizontal;
  }

  #left, #right { width: 300px; }

  #center {
    -webkit-box-flex: 1;
       -moz-box-flex: 1;
  }
</style>

<div id="container">
  <div id="top"></div>
  <div id="middle">
    <div id="left"></div>
    <div id="center"></div>
    <div id="right"></div>
  </div>
  <div id="bottom"></div>
</div>

Layered content

In CSS, with position:absolute, you can overlay your UI elements. On Android, you can use FrameLayout to achieve this. The child views in a frame layout are laid out on top of each other, with optional layout_gravity attributes indicating alignment with the parent frame layout.

Below is a contrived example of a FrameLayout with three children.

Figure: Example FrameLayout with three children (2 with top-left and 1 bottom-right alignment)

Figure: Isometric view of the example FrameLayout and its children.

The code for this example is as follows:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="300dp"
    android:layout_height="200dp">

    <!-- bottom-most child, with bottom-right alignment -->
    <View android:layout_gravity="bottom|right"
        android:layout_width="100dp"
        android:layout_height="150dp" />

    <!-- middle child, with top-left alignment -->
    <View android:layout_gravity="top|left"
        android:layout_width="200dp"
        android:layout_height="175dp" />

    <!-- top-most child, with top-left alignment →
    <!-- also stretched to fill vertically -->
    <View android:layout_gravity="top|left"
        android:layout_width="100dp"
        android:layout_height="match_parent" />

</FrameLayout>

Scrollable content

HTML, by default, flows in reading order and scrolls vertically. When content extends beyond the bottom of the browser, scrollbars automatically appear. Content panes can also be made individually scrollable using overflow:scroll or overflow:auto.

Android screen content isn’t scrollable by default. However, many content Views such as ListView and EditText offer scrolling, and any layout can be made scrollable by wrapping it in a ScrollView or HorizontalScrollView.

It’s also possible to add custom scrolling to views by using methods like View.scrollTo and helpers like Scroller in response to touch events. And for horizontal, snap-to-page-bounds scrolling, one can use the excellent new ViewPager class in the support library.

Below is an example of a ScrollView containing a single TextView child and the code needed to implement something like this.

Figure: A TextView inside a ScrollView, scrolled about half way.


<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- the scrollable content -->
    <TextView android:layout_gravity="bottom|right"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="32dp"
        android:textSize="48sp"
        android:text="The\nquick\nbrown\nfox\njumps\nover..." />

</ScrollView>

Custom layouts

Sometimes the positioning and layout behaviors you can achieve with CSS aren’t enough to achieve your desired layout. In those cases, developers fall back on JavaScript coupled with absolute positioning to place and size elements as needed.

Programmatically defined layouts are also possible on Android. In fact, they’re sometimes the most elegant and/or performant way of implementing a unique or otherwise tricky layout. Not happy with nesting LinearLayouts for implementing a 2x3 grid of navigation icons? Just extend ViewGroup and implement your own layout logic! (see an example DashboardLayout here). All the built-in layouts such as LinearLayout, FrameLayout, and RelativeLayout are implemented this way, so there generally aren’t the same performance implications with custom layouts as there are with scripted layout on the web.

Device densities

Web designers have long dealt with the reality that display densities vary, and that there wasn’t much they could do about it. This meant that for a long time web page graphics and UI elements had different physical sizes across different displays. Your 100px wide logo could be 1” wide on a desktop monitor or ¾” on a netbook. This was mostly OK, given that (a) pointing devices such as mice offered generally good precision in interacting with such elements and (b) browsers allowed visually-impaired users to zoom pages arbitrarily.

However, on touch-enabled mobile devices, designers really need to begin thinking about physical screen size, rather than resolution in pixels. A 100px wide button on a 120dpi (low density) device is ~0.9” wide while on a 320dpi (extra-high density) screen it’s only ~0.3” wide. You need to avoid the fat-finger problem, where a crowded space of small touch targets coupled with an imprecise pointing tool (your finger) leads to accidental touches. The Android framework tries really hard to take your layout and scale elements up or down as necessary to work around device-density differences and get a usable result on a wide range of them. This includes the browser, which scales a 160px <img> at 100% browser zoom up to 240px on a 240dpi screen, such that its physical width is always 1”.

Developers can achieve finer-grained control over this browser scaling by providing custom stylesheets and images for different densities, using CSS3 media query filters such as -webkit-max-device-pixel-ratio and <meta> viewport arguments such as target-densitydpi=device-dpi. For an in-depth discussion on how to tame this mobile browser behavior see this blog post: Pixel-perfect Android web UIs.

For native Android apps, developers can use resource directory qualifiers to provide different images per density (such as drawable-hdpi and drawable-mdpi). In addition, Android offers a special dimension unit called ‘density independent pixels’ (dp) which can (and should!) be used in layout definitions to offset the density factors and create UI elements that have consistent physical sizes across screens with different densities.

Features you don’t have out of the box

There are a few features that web designers and developers rely on that aren’t currently available in the Android UI toolkit.

Developers can defer to user-driven browser zooming and two-dimensional panning for content that is too small or too large for its viewport, respectively. Android doesn’t currently provide an out-of-the-box mechanism for two-dimensional layout zooming and panning, but with some extra legwork using existing APIs, these interactions are possible. However, zooming and panning an entire UI is not a good experience on mobile, and is generally more appropriate for individual content views such as lists, photos, and maps.

Additionally, vector graphics (generally implemented with SVG) are gaining in popularity on the Web for a number of reasons: the need for resolution independence, accessibility and ‘indexability’ for text-heavy graphics, tooling for programmatic graphic generation, etc. Although you can’t currently drop an SVG into an Android app and have the framework render it for you, Android’s version of WebKit supports SVG as of Android 3.0. As an alternative, you can use the very robust Canvas drawing methods, similar to HTML5’s canvas APIs, to render vector graphics. There are also community projects such as svg-android that support rendering a subset of the SVG spec.

Conclusion

Web developers have a number of different tools for frontend layout and styling at their disposal, and there are analogues for almost all of these in the world of Android UI engineering. If you’re wondering about analogues to other web- or CSS-isms, start a conversation out there in the Android community; you’ll find you’re not alone.

Nuevos descubrimientos sobre la villa y muralla de Adriano

June 20, 2011 By: (author unknown) Category: 1

Shared by Victor
ayazgos... http://desmotivaciones.es/demots/201103/imagesCAHIAV57.jpg

adriano.jpg

El emperador Adriano fue uno de los emperadores más famosos de Roma, vigente en el apogeo del Imperio 117-138 dC. Su villa al norte de Roma es una de las atracciones turísticas más populares, aún así, lo que no muchos saben es que se ha descubierto que los edificios del conjunto arquitectónico están alineados según parámetros astronómicos.

En el solsticio de verano (21 de junio de este año) la luz pasará a través de una abertura por encima de una puerta y señalará un pequeño nicho en la pared opuesta. El nicho probablemente contenía la estatua de una deidad. Este tipo de efecto de la luz se ha encontrado en algunos ayazagos del mundo antiguo como por ejemplo en Egipto.

Otro edificio se alinea tanto para el verano y el invierno (21 de diciembre de este año) , en los solsticios, durante el cual la luz brilla a través de una hilera de puertas.

Los efectos pueden haber sido parte de la adoración de Isis. Originalmente como muchos de vosotros sabéis fue una diosa egipcia, aunque en el imperio romano tuvo gran popularidad también.

Otro famoso monumento relacionado con Adriano, la famosa muralla, es noticia por un descubrimiento reciente. En el fuerte de Vindolanda, las decenas de chozas circulares que allí se encuentran parecen no tener nada que ver con las que los romanos construyeron.

De hecho, se asemejan a las chozas de las tribus que viven al norte de la muralla, en Escocia, y que estaban fuera de la influencia directa del imperio. Las conjetura a la que se ha llegado es que deben haber sido los refugiados de las tribus amistosas que huían de enemigos comunes o bien podrían ser las casas de los trabajadores temporales que vivían a lo largo de la pared y que sirvieron a los romanos.

Vía | Gadling
Imagen | Rafa
En Diario del Viajero | Roma: el Castillo de Sant’Angelo



Asus Padfone Fully Exposed (Images)

May 30, 2011 By: (author unknown) Category: Uncategorized

Shared by ianus
Ya se lo k kiero por Navidad! ;)
Thanks to: http://pocketnow.com/android/asus-padfone-fully-exposed-images

This is the Asus Padfone being introduced tomorrow: a package consisting of an Android smartphone and tablet to dock it with. Dock inside is more appropriate, as the "fone" appears to be fully consumed by the "Pad" when the two are merged.

asus padfone hero

Details are not yet clear on how this arrangement will work, but one thing we can discern from the renders is that Asus has indeed kept good on its word to continue a licensing arrangement with former hardware partner Garmin. Full specs and functionality will be very likely be revealed tomorrow at Computex in Taiwan, and we're quite interested to see how the Motorola Webtop paradigm translates to the tablet world.

asus padfone slate


asus padfone back

We also expect the tablet to be available in two colors: copper and black. To save on costs and to fully take advantage of the unique integration between the phone and the tablet, ASUS will allow the camera lens to "show through" a hole in the cover that protects the phone. From this view we can also see a pair of speaker meshes, which suggests that the tablet has dual speakers.

asus padfone flat

BBC News – Amazon sells ad-subsidised Kindle e-book reader

April 12, 2011 By: (author unknown) Category: 1

Shared by ianus
Thanks to:
http://www.bbc.co.uk/news/technology-13047300

The retail giant has started taking orders in the US for the device, which costs $114 (£69) - $25 (£15) less than the current entry level model.

The 'Kindle with Special Offers' will display sponsored messages from the likes of Olay and Visa.

It will also present readers with details of other Amazon products.

The company would not confirm if an advertising-subsidised Kindle was coming to the the UK market.

"We do not speculate on future products," a spokesperson said.

Amazon said that the advertisements on the 'Kindle with Special Offers' would not interrupt reading, appearing only at the bottom of the Kindle's home screen and while the device is in its idle state.

Un-sponsored versions of the Kindle feature black and white images of iconic authors when not in use.

Amazon will also launch 'AdMash', a service which that allows users to vote on which screensaver ads they prefer.

The revised device is physically identical to the current WiFi-only model which retails in the UK for £111.

Kindle has proved incredibly popular with readers since it launched in November 2007, costing $399 (£241).

Google Search app for iPhone—a new name and a new look

March 15, 2011 By: Julie Z Category: google

If you need to do a Google search on your iPhone or iPod touch it's now faster and easier when you use our redesigned Google Search app, formerly Google Mobile App. If you've been using Google Mobile App for a while, you'll notice that things look different.

The redesigned home screen of Google Search app.


First, you’ll see that there are now more ways to interact with the app. When browsing through search results or looking at a webpage, you can swipe down to see the search bar or change your settings. For those who use other Google apps, there’s an Apps button at the bottom of the screen for rapid access to the mobile versions of our products.

We also included a new toolbar that will make it easier for you to filter your results. You can open this toolbar by swiping from left to right — either before you search or once you’ve got your results. If you only want images, just tap “Images,” and the results will update as shown:


The toolbar helps you to get to the right kind of results.

Second, we’ve made it easier to pick up searching where you left off. If you leave the app and come back later, you’ll be able either to start a new search right away (just tap in the search box to type, hit the microphone button to do a voice search or tap on the camera icon to use Google Goggles) or get back to exactly where you were by tapping on the lower part of the page.

Finally, there are a number of improvements we’ve made to everything else you love in the app, including Google Goggles, Voice Search, Search with My Location, Gmail unread counts and more. There's a lot in the app, so we've added a simple help feature to let you explore it. Access this by tapping the question mark above the Google logo.

The help screen can be accessed from anywhere in Google Search app.




Download and try Google Search app today; it’s available free from the iTunes App Store. You can also scan the QR code below.


Posted by Alastair Tse, Software Engineer and Robert Hamilton, Product Manager

Google set to buy image search engine Like.com

August 17, 2010 By: (author unknown) Category: 1, google

Shared by ianus
otra compra?
Pero cuenta pela tiene?
Google Inc. is on the verge of acquiring Like.com, a search engine that allows consumers to search for products using images, reported the TechCrunch blog Sunday.

The Internet giant is "in the final stages of acquiring Like.com...for something north of $100 million," the technology news blog said, citing multiple unnamed sources.

July 06, 2010

July 07, 2010 By: (author unknown) Category: 1

Shared by ianus
Cassini Images Bizarre Hexagon On Saturn

ScienceDaily (Mar. 27, 2007) — An odd, six-sided, honeycomb-shaped feature circling the entire north pole of Saturn has captured the interest of scientists with NASA's Cassini mission.
http://www.sciencedaily.com/releases/2007/03/070327121941.htm

COMICS!

Search more securely with encrypted Google web search

May 21, 2010 By: A Googler Category: 1, google

As people spend more time on the Internet, they want greater control over who has access to their online communications. Many Internet services use what are known as Secure Sockets Layer (SSL) connections to encrypt information that travels between your computer and their service. Usually recognized by a web address starting with “https” or a browser lock icon, this technology is regularly used by online banking sites and e-commerce websites. Other sites may also implement SSL in a more limited fashion, for example, to help protect your passwords when you enter your login information.

Years ago Google added SSL encryption to products ranging from Gmail to Google Docs and others, and we continue to enable encryption on more services. Like banking and e-commerce sites, Google’s encryption extends beyond login passwords to the entire service. This session-wide encryption is a significant privacy advantage over systems that only encrypt login pages and credit card information. Early this year, we took an important step forward by making SSL the default setting for all Gmail users. And today we’re gradually rolling out a new choice to search more securely at https://www.google.com.

When you search on https://www.google.com, an encrypted connection is created between your browser and Google. This secured channel helps protect your search terms and your search results pages from being intercepted by a third party on your network. The service includes a modified logo to help indicate that you’re searching using SSL and that you may encounter a somewhat different Google search experience, but as always, remember to check the start of the address bar for “https” and your browser lock indicators:

Today’s release comes with a “beta” label for a few reasons. First, it currently covers only the core Google web search product. To help avoid misunderstanding, when you search using SSL, you won’t see links to offerings like Image Search and Maps that, for the most part, don’t support SSL at this time. Also, since SSL connections require additional time to set up the encryption between your browser and the remote web server, your experience with search over SSL might be slightly slower than your regular Google search experience. What won’t change is that you will still get the same great search results.

A few notes to remember: Google will still maintain search data to improve your search quality and to provide better service. Searching over SSL doesn’t reduce the data sent to Google — it only hides that data from third parties who seek it. And clicking on any of the web results, including Google universal search results for unsupported services like Google Images, could take you out of SSL mode. Our hope is that more websites and services will add support for SSL to help create a better and more consistent experience for you.

We think users will appreciate this new option for searching. It’s a helpful addition to users’ online privacy and security, and we’ll continue to add encryption support for more search offerings. To learn more about using the feature, refer to our help article on search over SSL.

Posted by Evan Roseman, Software Engineer

Dante’s Internet

February 18, 2010 By: Paul Tassi Category: 1

dantes-internet.jpg

(click to enlarge)

In the year or so since I started blogging, I’ve found myself ingrained into a number of internet communities which will here remain unnamed. But I have stumbled a cross an unwritten set of rules governing these communities, and someone took these general principles and fashioned them into this handy “Dante’s Inferno” type chart.

I would think Spammers would be a bit deeper into the bowels of hell, but I definitely agree with People Who Talk at the Theater being at the bottom. I can never watch Paranormal Activity for the first time again you assholes! In any case, I’d be curious to see some ambitious author write a parody book about Internet Dante making his way through all these circles and battling trolls and what not. I’d write it myself, but I’m too busy correcting other people’s spelling and grammar.