<attr name="visibility">
<!-- Visible on screen; the default value. -->
<enum name="visible" value="0" />
<!-- Not displayed, but taken into account during layout (space is left for it). -->
<enum name="invisible" value="1" />
<!-- Completely hidden, as if the view had not been added. -->
<enum name="gone" value="2" />
</attr>
button.setBackgroundColor(Color.WHITE);
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
button.setBackgroundColor(Color.WHITE);
} else button.setBackgroundColor(Color.RED);
return false;
}
});
int n = 6;
if (n % 2 == 0) {
int[][] matrix = new int[n][n];
for (int i = 0; i < matrix.length / 2; ++i) {
for (int j = i; j < n - i; j++) {
matrix[i][j] = 1;
matrix[matrix.length - i - 1][j] = 1;
}
}
for (int i = 0; i < matrix.length; i++, System.out.println())
for (int j = 0; j < matrix[i].length; j++)
System.out.print(matrix[i][j] + " ");
} else {
System.out.println("Некорректные данные");
}