Bonjour,
Je n'arrive pas a définir la taille d'un bouton dans mon application.
1er solution utiliser setWidth, l'image s'affiche bien mais le bouton a toujours la même taille.
2eme solutions utiliser setMaxWidth, l'image s'affiche bien mais le bouton a toujours la même taille (comme la solution1).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 bouton = new Button(this); bouton.setBackgroundResource(android.R.drawable.ic_menu_camera); bouton.setWidth(10); row.addView(bouton); table.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
3eme solutions utiliser un LinearLayout, l'image ne s'affiche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 bouton = new Button(this); bouton.setBackgroundResource(android.R.drawable.ic_menu_camera); bouton.setMaxWidth(10); row.addView(bouton); table.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Je suis a cour d'idée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 line=new LinearLayout(this); bouton = new Button(this); bouton.setBackgroundResource(android.R.drawable.ic_menu_camera); line.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); line.addView(bouton); row.addView(line); table.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 TableLayout table; LinearLayout line; Button bouton;
Partager