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.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
/**
|
||||
|
@ -9,10 +10,18 @@ import android.widget.ScrollView;
|
|||
*/
|
||||
public class CustomScrollView extends ScrollView {
|
||||
|
||||
private OnScrollChangedListener listener;
|
||||
private OnTouchEventListener onTouchEventListener;
|
||||
|
||||
public void setOnScrollChangedListener(OnScrollChangedListener listener){
|
||||
this.listener = listener;
|
||||
@Override
|
||||
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) {
|
||||
|
@ -23,13 +32,7 @@ public class CustomScrollView extends ScrollView {
|
|||
super(context,attributeSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
if(listener!=null)
|
||||
listener.onScrollChanged(l,t,oldl,oldt);
|
||||
}
|
||||
|
||||
public interface OnScrollChangedListener{
|
||||
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
||||
public interface OnTouchEventListener {
|
||||
public boolean onTouchEvent(MotionEvent ev);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,11 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
@ -36,9 +38,10 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
private static final int ENTRIES_PADDING_RIGHT = 15;
|
||||
|
||||
private TableLayout entriesTable;
|
||||
private CustomScrollView entriesScrollView;
|
||||
private ScrollView entriesScrollView;
|
||||
private FrameLayout headerFrame;
|
||||
private RelativeLayout rootView;
|
||||
private HorizontalScrollView horizontalScrollView;
|
||||
private TableRow.LayoutParams layoutParams;
|
||||
private TableRow headerRow;
|
||||
|
||||
|
@ -48,7 +51,7 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
private int page;
|
||||
private int pageCount;
|
||||
private ProgressBar progressBar;
|
||||
private ScrollView fakeScrollView;
|
||||
private CustomScrollView fakeScrollView;
|
||||
private View dummyView;
|
||||
|
||||
private MenuInflater menuInflater;
|
||||
|
@ -82,17 +85,20 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
private void initViewItems(View rootView){
|
||||
headerFrame = (FrameLayout) rootView.findViewById(R.id.headerFrame);
|
||||
entriesTable = (TableLayout) rootView.findViewById(R.id.entriesTable);
|
||||
entriesScrollView = (CustomScrollView) rootView.findViewById(R.id.entriesScrollView);
|
||||
fakeScrollView = (ScrollView) rootView.findViewById(R.id.fakeScroll);
|
||||
entriesScrollView = (ScrollView) rootView.findViewById(R.id.entriesScrollView);
|
||||
fakeScrollView = (CustomScrollView) rootView.findViewById(R.id.fakeScroll);
|
||||
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
||||
dummyView = rootView.findViewById(R.id.dummyView);
|
||||
horizontalScrollView = (HorizontalScrollView) rootView.findViewById(R.id.horizontalScrollView);
|
||||
|
||||
this.rootView = (RelativeLayout) rootView;
|
||||
|
||||
entriesScrollView.setOnScrollChangedListener(new CustomScrollView.OnScrollChangedListener() {
|
||||
fakeScrollView.setOnTouchEventListener(new CustomScrollView.OnTouchEventListener() {
|
||||
@Override
|
||||
public void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
fakeScrollView.scrollTo(0,t);
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
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);
|
||||
int height = entriesScrollView.getMeasuredHeight();
|
||||
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"
|
||||
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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -33,7 +20,7 @@
|
|||
android:id="@+id/headerFrame"
|
||||
></FrameLayout>
|
||||
|
||||
<info.nerull7.mysqlbrowser.CustomScrollView
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/entriesScrollView"
|
||||
|
@ -44,7 +31,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/entriesTable">
|
||||
</TableLayout>
|
||||
</info.nerull7.mysqlbrowser.CustomScrollView>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</HorizontalScrollView>
|
||||
|
||||
|
@ -58,4 +45,18 @@
|
|||
android:layout_alignParentTop="false"
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue