diff --git a/android/res/layout/piano2.xml b/android/res/layout/piano2.xml index 513f9d4..97e7ed4 100644 --- a/android/res/layout/piano2.xml +++ b/android/res/layout/piano2.xml @@ -61,6 +61,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> + diff --git a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java index 062525c..0d0bda0 100644 --- a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java +++ b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java @@ -32,8 +32,8 @@ import com.levien.synthesizer.core.midi.MidiListener; public class KeyboardView extends View { public KeyboardView(Context context, AttributeSet attrs) { super(context, attrs); - nKeys_ = 36; // TODO: make configurable - firstKey_ = 36; + nKeys_ = 25; // TODO: make configurable + firstKey_ = 48; noteStatus_ = new byte[128]; noteForFinger_ = new int[FINGERS]; for (int i = 0; i < FINGERS; i++) { @@ -136,6 +136,9 @@ public class KeyboardView extends View { int width = 0; int height = 0; + float density = getResources().getDisplayMetrics().density; + int maxHeight = (int) (300.0f * density + 0.5f); + switch (widthMode) { case MeasureSpec.EXACTLY: width = widthSize; @@ -153,7 +156,7 @@ public class KeyboardView extends View { height = heightSize; break; case MeasureSpec.AT_MOST: - height = heightSize; + height = Math.min(maxHeight, heightSize); break; case MeasureSpec.UNSPECIFIED: height = 10;