2017-05-16 4 views
0

navigation open 웹보기에서 다른 웹 사이트를 열어도 안드로이드 앱을 만들지 만 월마트 웹 사이트를 열면 내 웹 사이트 탐색 바를 내릴 때 웹 사이트 탐색 바에 문제가 있습니다. 꼭대기에 오르지 마라. Scroll for going on top of navigation top but not scroll going swipe to refreshandroid 웹보기 스 와이프 웹 사이트 탐색 바에서 새로 고침

내 xml 파일은 다음과 같습니다 -

`<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeContainer" 
    android:layout_width="match_parent" 
    android:layout_below="@+id/progressBar" 
    android:layout_height= "match_parent"> 


    <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
</android.support.v4.widget.SwipeRefreshLayout>` 

내 자바 코드는 다음과 같습니다 -

public class MainActivity extends AppCompatActivity { 
private WebView myWebView; 
Context context; 
Toolbar toolbar; 
ProgressBar progressBar; 
SwipeRefreshLayout mySwipeRefreshLayout; 
WebSettings settings; 

RelativeLayout relativeLayout; 

@SuppressLint("SetJavaScriptEnabled") 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    myWebView = (WebView) findViewById(R.id.webView1); 
    myWebView.setWebViewClient(new WebViewClientDemo()); 
    myWebView.setWebChromeClient(new WebChromeClientDemo()); 
    myWebView.getSettings().setJavaScriptEnabled(true); 
    myWebView.loadUrl("https://www.walmart.com/"); 
    myWebView.getSettings().setDomStorageEnabled(true); 
    mySwipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipeContainer); 

    mySwipeRefreshLayout.setOnRefreshListener(
      new SwipeRefreshLayout.OnRefreshListener() { 
       @Override 
       public void onRefresh() { 
        myWebView.reload(); 
       } 
      } 
    ); 

    mySwipeRefreshLayout.setNestedScrollingEnabled(false); 

죄송합니다 나쁜 영어 사전에 감사합니다.

답변

0

1 단계 : 스크롤 위치가 완전히 아래로 스 와이프되면 즉 y 위치가 0 일 때 스크롤해야 볼 수 있습니다.

2 단계 : canChileScrollUp() 방법

이를 사용하여 작업을 수행 할 수는 그것이 새로 고쳐지지 않습니다 false를 반환하는 경우, "canChildScrollUp는"새로 고치거나하지 않도록 날씨를 감지하는 기능을 가지고 사용자 정의 refreshlayout입니다.

"canSwipeRefreshChildScrollUp"은 (는) 당신의 논리를 활동에 쓸 곳입니다.

public class YourActivity implements CustomSwipeRefreshLayout.CanChildScrollUpCallback { 

private CustomSwipeRefreshLayout mRefreshLayout; 
private WebView mWebView; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // after initialization 
    mRefreshLayout.setCanChildScrollUpCallback(this); 
} 

@Override 
public boolean canSwipeRefreshChildScrollUp() { 
    return mWebview.getScrollY() > 0; 
} 
} 

중첩 된 스크롤을 감지 UR 경우 사용 사용자 정의 웹보기에서 스크롤 위치를 감지하고 스크롤이 완전히 다음 완료되는 경우에만 활동에서 진정한

public class CustomSwipeRefreshLayout extends SwipeRefreshLayout { 

private CanChildScrollUpCallback mCanChildScrollUpCallback; 

public interface CanChildScrollUpCallback { 
    boolean canSwipeRefreshChildScrollUp(); 
} 

public void setCanChildScrollUpCallback(CanChildScrollUpCallback canChildScrollUpCallback) { 
    mCanChildScrollUpCallback = canChildScrollUpCallback; 
} 

@Override 
public boolean canChildScrollUp() { 
    if (mCanChildScrollUpCallback != null) { 
     return mCanChildScrollUpCallback.canSwipeRefreshChildScrollUp(); 
    } 
    return super.canChildScrollUp(); 
} 
} 

을 반환이

을 사용할 수 있습니다
public class MyWebView extends WebView{ 
@Override 
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { 
    if(clampedX || clampedY){ 
     //Content is not scrolling 
     //TODO Enable SwipeRefreshLayout 
    } 
} 
@Override 
public boolean onTouchEvent(MotionEvent event) { 
    if(event.getActionMasked()==MotionEvent.ACTION_UP){ 
     //TODO Disable SwipeRefreshLayout 
    } 
} 
} 
+0

xml에 대한 설명을 –

+0

xml에 변경하지 않아도됩니다. –

+0

코드 구현에 대해 자세히 설명해주십시오. –

관련 문제