je la vue suivante: ImageView montrant les données précédente vue de l'image
dans lequel, si je clique sur une ImageButton Affiche l'image respective en plein écran mode.For exemple, si je clique sur noir, il montre une vue de l'image, comme:
aussi je tâche de fond à la couleur plein écran pour certains imagebuttons comme ceci: si je clique rose, il montre la couleur rose clair:
Upto maintenant son tout ok, si je clique sur le bouton noir d'abord, puis je clique sur le rose, l'image sur le noir est porté à la mise en page avec un fond rose, comme ceci:
Ceci est mon problème, je veux seulement rose, pas l'image au premier plan;
Ceci est mon fichier XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#657383" >
<ImageView android:id="@+id/imv"
android:contentDescription="@string/app_name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
/>
<Button android:id="@+id/home"
android:contentDescription="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="@string/Back_Button"
android:textSize="25sp"
/>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton android:id="@+id/image1"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:background="#000000"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"/>
<ImageButton android:id="@+id/image2"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:layout_toRightOf="@+id/image1"
android:background="#ff0000"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"/>
<ImageButton android:id="@+id/image3"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:layout_below="@+id/image1"
android:background="#00ff00"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
/>
<ImageButton android:id="@+id/image4"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:background="#0000ff"
android:layout_below="@+id/image2"
android:layout_toRightOf="@+id/image3"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
/>
<ImageButton android:id="@+id/image5"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:background="#FFFF00"
android:layout_below="@+id/image3"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
/>
<ImageButton android:id="@+id/image6"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:layout_below="@+id/image4"
android:layout_toRightOf="@+id/image5"
android:background="#FFA500"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"/>
<ImageButton android:id="@+id/image7"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:layout_below="@+id/image5"
android:background="#FFFFFF"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"/>
<ImageButton android:id="@+id/image8"
android:contentDescription="@string/hello_world"
android:layout_width="130dp"
android:layout_height="95dp"
android:layout_below="@+id/image6"
android:background="#F52887"
android:layout_toRightOf="@+id/image7"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
données Mon .java est:
private OnClickListener myListener = new OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
handler.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
iv.setVisibility(View.GONE);
}
}, 2500);
if (v.getId() == R.id.image1) {
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setImageResource(R.drawable.ic_launcher);
} else if(v.getId() == R.id.image2){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setImageResource(R.drawable.kids_paint_hands);
}else if(v.getId() == R.id.image3){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setImageResource(R.drawable.play_logo);
}else if(v.getId() == R.id.image4){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setBackgroundColor(Color.BLUE);
}else if(v.getId() == R.id.image5){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setBackgroundColor(Color.CYAN);
}else if(v.getId() == R.id.image6){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setBackgroundColor(Color.MAGENTA);
}else if(v.getId() == R.id.image7){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setBackgroundColor(Color.WHITE);
}else if(v.getId() == R.id.image8){
iv.setBackground(null);
iv.setVisibility(View.VISIBLE);
iv.setBackgroundColor(Color.DKGRAY);
iv.clearFocus();
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
Toute aide ou suggestion?
envoyer votre code, vous pouvez régler la visibilité de l'image pour aller – Pragnani
S'il vous plaît ajouter votre code si vous faites passer de plein écran en cliquant sur le bouton, afin que nous puissions voir votre erreur le cas échéant, et vous aider. – Rekha
@Pragnani: Juste mis à jour mon code avec Java classe – sai