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

@ -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;

Loading…
Cancel
Save