Ajouter semi-transparente superposition de l'activité de fond au moment de l'exécution

J'ai une application que j'ai mis en arrière-plan d'une image à partir de xml. J'obtiens l'affichage en appelant

setContentView(R.)

.
Comment puis-je placer un semi-transparente superposition sur cette toile de fond au moment de l'exécution en fonction d'une condition. Je voudrais avoir une incrustation rouge avec son alpha fixé à 50%.

J'ai essayé de créer un autre fichier xml avec le point de vue de reproduire et de l'image/de superposition, mais son désordre que j'ai pour gonfler tous les boutons/textview lorsque j'utilise le nouveau point de vue.

merci matt

[edit1]

<?xml version="1.0" encoding="utf-8"?>

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/carefreebgscaledlighting"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">


    <TextView
        android:id="@+id/textviewcompanyname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87" />

    <TextView
        android:id="@+id/textViewYouAreSignedIn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_alignParentTop="true"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87"
         />

          <TextView
        android:id="@+id/textViewUnsentTransactions"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_below="@id/textViewYouAreSignedIn"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87"
         />

[edit2]

<?xml version="1.0" encoding="utf-8"?>


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


     <RelativeLayout
        android:id="@+id/transparentOverlay"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/red_transparent" >


<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/carefreebgscaledlighting"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">




    <TextView
        android:id="@+id/textviewcompanyname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87" />

    <TextView
        android:id="@+id/textViewYouAreSignedIn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_alignParentTop="true"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87"
         />

[edit3]

<?xml version="1.0" encoding="utf-8"?>


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



<LinearLayout 
    android:id="@+id/ll1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/carefreebgscaledlighting"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">




    <TextView
        android:id="@+id/textviewcompanyname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#003F87" />

.

if(status.equalsIgnoreCase(IN)){

                youAreSignedInAt.setText("You are signed in at " + name);
                LinearLayout layout =(LinearLayout)findViewById(R.id.ll1);
                layout.setBackgroundResource(R.drawable.carefreebgscaledlightingred);
            }else{

                youAreSignedInAt.setText("You are not signed in");
                LinearLayout layout =(LinearLayout)findViewById(R.id.ll1);
                layout.setBackgroundResource(R.drawable.carefreebgscaledlighting);
            }
  • Si vous savez comment opaque vous voulez qu'il soit, pourquoi pas un PNG? Ce sera juste une image que vous pouvez ajouter à la mise en page, chaque fois que nécessaire.
InformationsquelleAutor turtleboy | 2013-09-27