Fix hidden Scrollbar
This commit is contained in:
parent
5ea924f149
commit
8f69536a70
3 changed files with 48 additions and 33 deletions
|
@ -2,6 +2,7 @@ package info.nerull7.mysqlbrowser;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,10 +10,18 @@ import android.widget.ScrollView;
|
||||||
*/
|
*/
|
||||||
public class CustomScrollView extends ScrollView {
|
public class CustomScrollView extends ScrollView {
|
||||||
|
|
||||||
private OnScrollChangedListener listener;
|
private OnTouchEventListener onTouchEventListener;
|
||||||
|
|
||||||
public void setOnScrollChangedListener(OnScrollChangedListener listener){
|
@Override
|
||||||
this.listener = listener;
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
|
if(onTouchEventListener != null){
|
||||||
|
onTouchEventListener.onTouchEvent(ev);
|
||||||
|
}
|
||||||
|
return super.onTouchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnTouchEventListener(OnTouchEventListener onTouchEventListener){
|
||||||
|
this.onTouchEventListener = onTouchEventListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomScrollView(Context context) {
|
public CustomScrollView(Context context) {
|
||||||
|
@ -23,13 +32,7 @@ public class CustomScrollView extends ScrollView {
|
||||||
super(context,attributeSet);
|
super(context,attributeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public interface OnTouchEventListener {
|
||||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
public boolean onTouchEvent(MotionEvent ev);
|
||||||
if(listener!=null)
|
|
||||||
listener.onScrollChanged(l,t,oldl,oldt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnScrollChangedListener{
|
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@ import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
@ -36,9 +38,10 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
private static final int ENTRIES_PADDING_RIGHT = 15;
|
private static final int ENTRIES_PADDING_RIGHT = 15;
|
||||||
|
|
||||||
private TableLayout entriesTable;
|
private TableLayout entriesTable;
|
||||||
private CustomScrollView entriesScrollView;
|
private ScrollView entriesScrollView;
|
||||||
private FrameLayout headerFrame;
|
private FrameLayout headerFrame;
|
||||||
private RelativeLayout rootView;
|
private RelativeLayout rootView;
|
||||||
|
private HorizontalScrollView horizontalScrollView;
|
||||||
private TableRow.LayoutParams layoutParams;
|
private TableRow.LayoutParams layoutParams;
|
||||||
private TableRow headerRow;
|
private TableRow headerRow;
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
private int page;
|
private int page;
|
||||||
private int pageCount;
|
private int pageCount;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private ScrollView fakeScrollView;
|
private CustomScrollView fakeScrollView;
|
||||||
private View dummyView;
|
private View dummyView;
|
||||||
|
|
||||||
private MenuInflater menuInflater;
|
private MenuInflater menuInflater;
|
||||||
|
@ -82,17 +85,20 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
private void initViewItems(View rootView){
|
private void initViewItems(View rootView){
|
||||||
headerFrame = (FrameLayout) rootView.findViewById(R.id.headerFrame);
|
headerFrame = (FrameLayout) rootView.findViewById(R.id.headerFrame);
|
||||||
entriesTable = (TableLayout) rootView.findViewById(R.id.entriesTable);
|
entriesTable = (TableLayout) rootView.findViewById(R.id.entriesTable);
|
||||||
entriesScrollView = (CustomScrollView) rootView.findViewById(R.id.entriesScrollView);
|
entriesScrollView = (ScrollView) rootView.findViewById(R.id.entriesScrollView);
|
||||||
fakeScrollView = (ScrollView) rootView.findViewById(R.id.fakeScroll);
|
fakeScrollView = (CustomScrollView) rootView.findViewById(R.id.fakeScroll);
|
||||||
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
||||||
dummyView = rootView.findViewById(R.id.dummyView);
|
dummyView = rootView.findViewById(R.id.dummyView);
|
||||||
|
horizontalScrollView = (HorizontalScrollView) rootView.findViewById(R.id.horizontalScrollView);
|
||||||
|
|
||||||
this.rootView = (RelativeLayout) rootView;
|
this.rootView = (RelativeLayout) rootView;
|
||||||
|
|
||||||
entriesScrollView.setOnScrollChangedListener(new CustomScrollView.OnScrollChangedListener() {
|
fakeScrollView.setOnTouchEventListener(new CustomScrollView.OnTouchEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt) {
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
fakeScrollView.scrollTo(0,t);
|
entriesScrollView.onTouchEvent(ev);
|
||||||
|
horizontalScrollView.onTouchEvent(ev);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -259,6 +265,11 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
entriesScrollView.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED);
|
entriesScrollView.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED);
|
||||||
int height = entriesScrollView.getMeasuredHeight();
|
int height = entriesScrollView.getMeasuredHeight();
|
||||||
dummyView.setMinimumHeight(height);
|
dummyView.setMinimumHeight(height);
|
||||||
|
|
||||||
|
RelativeLayout.LayoutParams fakeScrollLayout = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
fakeScrollLayout.setMargins(0,headerFrame.getHeight(),0,0);
|
||||||
|
|
||||||
|
fakeScrollView.setLayoutParams(fakeScrollLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,6 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="info.nerull7.mysqlbrowser.EntriesFragment">
|
tools:context="info.nerull7.mysqlbrowser.EntriesFragment">
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_below="@+id/loginProgressBar"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:foregroundGravity="right"
|
|
||||||
android:id="@+id/fakeScroll">
|
|
||||||
<View
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/dummyView"/>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -33,7 +20,7 @@
|
||||||
android:id="@+id/headerFrame"
|
android:id="@+id/headerFrame"
|
||||||
></FrameLayout>
|
></FrameLayout>
|
||||||
|
|
||||||
<info.nerull7.mysqlbrowser.CustomScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/entriesScrollView"
|
android:id="@+id/entriesScrollView"
|
||||||
|
@ -44,7 +31,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/entriesTable">
|
android:id="@+id/entriesTable">
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
</info.nerull7.mysqlbrowser.CustomScrollView>
|
</ScrollView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
@ -58,4 +45,18 @@
|
||||||
android:layout_alignParentTop="false"
|
android:layout_alignParentTop="false"
|
||||||
android:layout_marginTop="-7dp" />
|
android:layout_marginTop="-7dp" />
|
||||||
|
|
||||||
|
<info.nerull7.mysqlbrowser.CustomScrollView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_below="@+id/loginProgressBar"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:foregroundGravity="right"
|
||||||
|
android:id="@+id/fakeScroll"
|
||||||
|
android:overScrollMode="never">
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/dummyView"/>
|
||||||
|
</info.nerull7.mysqlbrowser.CustomScrollView>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue