mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-20 12:42:18 +01:00
DroidFish: Improved handling of movelist scrolling when navigation bar
is enabled/disabled and when the analysis view gets smaller/larger.
This commit is contained in:
@@ -31,6 +31,7 @@ import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
/** Custom view for displaying move list.
|
||||
* This is much faster than using a TextView. */
|
||||
@@ -125,8 +126,14 @@ public class MoveListView extends View {
|
||||
createLayout(width);
|
||||
|
||||
int height = 0;
|
||||
if (layout != null)
|
||||
if (layout != null) {
|
||||
height = layout.getLineCount() * getLineHeight();
|
||||
ViewParent p = getParent();
|
||||
if (p != null)
|
||||
p = p.getParent();
|
||||
if (p instanceof MyRelativeLayout)
|
||||
height += -getLineHeight() + ((MyRelativeLayout)p).getNewHeight();
|
||||
}
|
||||
switch (MeasureSpec.getMode(heightMeasureSpec)) {
|
||||
case MeasureSpec.UNSPECIFIED:
|
||||
break;
|
||||
|
||||
31
DroidFish/src/org/petero/droidfish/MyRelativeLayout.java
Normal file
31
DroidFish/src/org/petero/droidfish/MyRelativeLayout.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.petero.droidfish;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
/** A RelativeLayout with the addition that child widgets can ask
|
||||
* about the new parent size during onMeasure(). */
|
||||
public class MyRelativeLayout extends RelativeLayout {
|
||||
private int newWidth;
|
||||
private int newHeight;
|
||||
|
||||
public MyRelativeLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
newWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
newHeight = MeasureSpec.getSize(heightMeasureSpec);
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
public int getNewWidth() {
|
||||
return newWidth;
|
||||
}
|
||||
|
||||
public int getNewHeight() {
|
||||
return newHeight;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ package org.petero.droidfish;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
/** A ScrollView that uses at most 75% of the parent height. */
|
||||
@@ -35,8 +34,8 @@ public class MyScrollView extends ScrollView {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int width = getMeasuredWidth();
|
||||
int height = getMeasuredHeight();
|
||||
if (getParent() instanceof View) {
|
||||
int parentHeight = ((View)getParent()).getHeight();
|
||||
if (getParent() instanceof MyRelativeLayout) {
|
||||
int parentHeight = ((MyRelativeLayout)getParent()).getNewHeight();
|
||||
if (parentHeight > 0)
|
||||
height = Math.min(height, parentHeight * 3 / 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user