我想知道如何在Gmail应用中实现淡入淡出效果。当您将手指拖动到导航抽屉并打开或关闭导航抽屉时,导航抽屉下方的视图会变得更亮或更暗(如果将其移到左侧,则会变得更亮,反之亦然)。Gmail导航抽屉效果
我试图做下面的代码,但它崩溃了,它不像Gmail应用程序视觉上好。
String colorString = "0x00000000";
int max = MAX_SIZE_X;
int auxMax = (int) (MAX_SIZE_X * 0.9); // 90
int betMax = (int) (MAX_SIZE_X * 0.8); // 80
int auxMaM = (int) (MAX_SIZE_X * 0.7); // 70
int betMaM = (int) (MAX_SIZE_X * 0.6); // 60
int auxMid = (int) (MAX_SIZE_X * 0.5); // 50
int betMid = (int) (MAX_SIZE_X * 0.4); // 40
int auxMiM = (int) (MAX_SIZE_X * 0.3); // 30
int betMiM = (int) (MAX_SIZE_X * 0.2); // 20
int betMin = (int) (MAX_SIZE_X * 0.1); // 10
if (touch < max && touch >= auxMax) {
colorString = "#88000000";
}
if (touch < auxMax && touch >= betMax) {
colorString = "#84000000";
}
if (touch < betMax && touch >= auxMaM) {
colorString = "#80000000";
}
if (touch < auxMaM && touch >= betMaM) {
colorString = "#76000000";
}
if (touch < betMaM && touch >= auxMid) {
colorString = "#72000000";
}
if (touch < auxMid && touch >= betMid) {
colorString = "#68000000";
}
if (touch < betMid && touch >= auxMiM) {
colorString = "#64000000";
}
if (touch < auxMiM && touch >= betMiM) {
colorString = "#60000000";
}
if (touch < betMiM && touch >= betMin) {
colorString = "#00000000";
}
colorInt = Color.parseColor(colorString);
return colorInt;
请添加更多的错误信息,最好的logcat的。 –