mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-01-30 17:13:50 +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:
parent
afcb7d2509
commit
8420e628e1
|
@ -75,10 +75,23 @@
|
|||
android:fontFamily="monospace"
|
||||
android:typeface="monospace"
|
||||
android:textSize="12sp"/>
|
||||
<RelativeLayout
|
||||
<view
|
||||
class="org.petero.droidfish.MyRelativeLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
<view
|
||||
class="org.petero.droidfish.MyScrollView"
|
||||
android:id="@+id/scrollViewBot"
|
||||
|
@ -94,20 +107,7 @@
|
|||
android:typeface="monospace"
|
||||
android:textSize="12sp"/>
|
||||
</view>
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_above="@+id/scrollViewBot"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</view>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<include layout="@layout/left_drawer"/>
|
||||
|
|
|
@ -69,10 +69,23 @@
|
|||
android:layout_height="32dp">
|
||||
</ImageButton>
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
<view
|
||||
class="org.petero.droidfish.MyRelativeLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
<view
|
||||
class="org.petero.droidfish.MyScrollView"
|
||||
android:id="@+id/scrollViewBot"
|
||||
|
@ -88,20 +101,7 @@
|
|||
android:typeface="monospace"
|
||||
android:textSize="12sp"/>
|
||||
</view>
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_above="@+id/scrollViewBot"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</view>
|
||||
</LinearLayout>
|
||||
<include layout="@layout/left_drawer"/>
|
||||
<include layout="@layout/right_drawer"/>
|
||||
|
|
|
@ -70,10 +70,23 @@
|
|||
android:fontFamily="monospace"
|
||||
android:typeface="monospace"
|
||||
android:textSize="12sp"/>
|
||||
<RelativeLayout
|
||||
<view
|
||||
class="org.petero.droidfish.MyRelativeLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
<view
|
||||
class="org.petero.droidfish.MyScrollView"
|
||||
android:id="@+id/scrollViewBot"
|
||||
|
@ -89,20 +102,7 @@
|
|||
android:typeface="monospace"
|
||||
android:textSize="12sp"/>
|
||||
</view>
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_above="@+id/scrollViewBot"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<view
|
||||
class="org.petero.droidfish.MoveListView"
|
||||
android:id="@+id/moveList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="true"
|
||||
android:padding="0dp"/>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</view>
|
||||
</LinearLayout>
|
||||
<view
|
||||
class="org.petero.droidfish.ChessBoardPlay"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user