Tweaking height of keyboard view

With these changes, there's a max height of 300dp, and a bit more room
in a phone layout (some of the hidden status message widgets were taking
vertical space).
master
Raph Levien 11 years ago
parent bb3bd340d4
commit 1c6027bc3b
  1. 2
      android/res/layout/piano2.xml
  2. 9
      android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java

@ -61,6 +61,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />
<!--
<TextView <TextView
android:id="@+id/status" android:id="@+id/status"
android:visibility="invisible" android:visibility="invisible"
@ -80,6 +81,7 @@
android:layout_height="40dp" android:layout_height="40dp"
android:textIsSelectable="true" android:textIsSelectable="true"
/> />
-->
</LinearLayout> </LinearLayout>
</TableRow> </TableRow>
<TableRow> <TableRow>

@ -32,8 +32,8 @@ import com.levien.synthesizer.core.midi.MidiListener;
public class KeyboardView extends View { public class KeyboardView extends View {
public KeyboardView(Context context, AttributeSet attrs) { public KeyboardView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
nKeys_ = 36; // TODO: make configurable nKeys_ = 25; // TODO: make configurable
firstKey_ = 36; firstKey_ = 48;
noteStatus_ = new byte[128]; noteStatus_ = new byte[128];
noteForFinger_ = new int[FINGERS]; noteForFinger_ = new int[FINGERS];
for (int i = 0; i < FINGERS; i++) { for (int i = 0; i < FINGERS; i++) {
@ -136,6 +136,9 @@ public class KeyboardView extends View {
int width = 0; int width = 0;
int height = 0; int height = 0;
float density = getResources().getDisplayMetrics().density;
int maxHeight = (int) (300.0f * density + 0.5f);
switch (widthMode) { switch (widthMode) {
case MeasureSpec.EXACTLY: case MeasureSpec.EXACTLY:
width = widthSize; width = widthSize;
@ -153,7 +156,7 @@ public class KeyboardView extends View {
height = heightSize; height = heightSize;
break; break;
case MeasureSpec.AT_MOST: case MeasureSpec.AT_MOST:
height = heightSize; height = Math.min(maxHeight, heightSize);
break; break;
case MeasureSpec.UNSPECIFIED: case MeasureSpec.UNSPECIFIED:
height = 10; height = 10;

Loading…
Cancel
Save