vendredi 11 novembre 2011

Transparency color with Android

How to get a transparency color in your Android Layout (or View) ?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:padding="5dp"
    android:fitsSystemWindows="true"
    android:id="@+id/scrollview1">

In the sample just above the background color is white and not transparent.

To transform this color like a transparent color, do like that :

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#80FFFFFF"
    android:padding="5dp"
    android:fitsSystemWindows="true"
    android:id="@+id/scrollview1">

Put the value 80 before the color !

Simple is Androïd.

2 commentaires:

  1. Ce ne serait pas plutôt android:background="#80FFFFFF"
    plutôt que
    android:background="#800FFFFF"
    si l'on veut respecter la couleur indiqué dans l'exemple au dessus ?

    RépondreSupprimer