Comment définir la valeur alpha pour ma mise en page relative?
Salut, je vais essayer de mettre en valeur alpha pour un membre de ma famille mise en page, mais, je suis d'erreur comment résoudre ce problème m'aider.....
J'ai trois de mise en page dans mon xml 1ère mise en page mise en page à l'aide de l'arrière-plan de la 2e mise en page à l'aide de l'en-tête 3ème mise en page à l'aide pour le pied de page. Je souhaite à l'ensemble de la valeur alpha 2 & 3 ° mise en page, donc je suis en train d'essayer de nombreuses façons, je n'ai encore aucune idée de s'il vous plaît dites comment mettre en valeur alpha
code xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:background="@drawable/blue">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60px"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:background="@drawable/gradient_black"
android:id="@+id/ttest">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:layout_toRightOf="@+id/imageView1"
android:text="settings"
android:textColor="@color/white"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="55px"
android:background="@drawable/gradient_black"
android:gravity="bottom"
android:orientation="horizontal"
android:layout_alignParentBottom="true" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ssss"
/>
</RelativeLayout>
</RelativeLayout>
code:
public class DesignActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int width = getWindowManager().getDefaultDisplay().getWidth();
int height = getWindowManager().getDefaultDisplay().getHeight();
ImageView imgHead = (ImageView)findViewById(R.id.imageView1);
ImageView imgbottom = (ImageView)findViewById(R.id.imageView2);
imgbottom.setImageResource(R.drawable.back);
imgbottom.setLayoutParams(new RelativeLayout.LayoutParams(width/8, height/8));
imgHead.setImageResource(R.drawable.b);
imgHead.setLayoutParams(new RelativeLayout.LayoutParams(width/8, height/8));
// RelativeLayout relative = (RelativeLayout)findViewById(R.id.ttest);
}
}
source d'informationauteur balaji
Vous devez vous connecter pour publier un commentaire.
essayer cette
Dans ces cas, en général j'ai tendance à vouloir définir la couleur et alpha en même temps, donc je viens de l'utiliser
rl.setBackgroundColor(0xAACCCCCC);
où A est la valeur alpha et C est la couleur, au format hex.e.g:
rl.setBackgroundColor(0x88000000);
pour 0,5 transparent fond noir.ou en XML:
android:background="#88000000"