Fix alpha in a floating keyboard

This commit is contained in:
serso 2016-03-15 21:02:14 +01:00
parent 8ccddf3fb1
commit 9f94f9fd90
3 changed files with 15 additions and 1 deletions

View File

@ -60,6 +60,9 @@ public abstract class BaseFloatingKeyboard implements FloatingKeyboard {
protected DirectionDragButton makeButton(@IdRes int id, @NonNull String text) { protected DirectionDragButton makeButton(@IdRes int id, @NonNull String text) {
final DirectionDragButton button = new DirectionDragButton(user.getContext()); final DirectionDragButton button = new DirectionDragButton(user.getContext());
fillButton(button, id); fillButton(button, id);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
button.setAllCaps(false);
}
button.setText(text); button.setText(text);
button.setTextColor(textColor); button.setTextColor(textColor);
button.setDirectionTextColor(textColorSecondary); button.setDirectionTextColor(textColorSecondary);
@ -104,6 +107,7 @@ public abstract class BaseFloatingKeyboard implements FloatingKeyboard {
final DirectionDragButton button = addButton(row, id, text); final DirectionDragButton button = addButton(row, id, text);
button.setBackgroundResource(R.drawable.material_button_light_primary); button.setBackgroundResource(R.drawable.material_button_light_primary);
button.setTextColor(Color.WHITE); button.setTextColor(Color.WHITE);
button.setDirectionTextAlpha(0.7f);
return button; return button;
} }

View File

@ -80,4 +80,10 @@ public class DirectionDragButton extends DragButton implements DirectionDragView
getText(direction).setColor(color); getText(direction).setColor(color);
} }
} }
public void setDirectionTextAlpha(float alpha) {
for (DragDirection direction : DragDirection.values()) {
getText(direction).setAlpha(alpha);
}
}
} }

View File

@ -156,7 +156,11 @@ public class DirectionTextView {
} }
public void setColor(int color) { public void setColor(int color) {
setColor(color, this.alpha); setColor(color, alpha);
}
public void setAlpha(float alpha) {
setColor(color, alpha);
} }
public void setColor(int color, float alpha) { public void setColor(int color, float alpha) {