2017-01-13 5 views
0

이전에 RL에서 오버레이보기가있는 조각에서 XWalkView를 사용하고있었습니다.Android XWalkView 레이아웃 문제

이제는 Acitvity에서 사용하고 싶었지만 레이아웃 렌더링 문제가 발생하고 Snackbar가 더 이상 작동하지 않습니다.

enter image description here

XML :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".GenerateActivity" 
    tools:showIn="@layout/activity_generate"> 

    <org.xwalk.core.XWalkView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 



    <!--<WebView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    </WebView>--> 


    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/btn_default" 
     android:elevation="4dp" 
     android:visibility="visible" 
     android:id="@+id/ll_seat_mode_info" 
     android:paddingLeft="10dp" 
     android:paddingRight="10dp" 
     android:paddingBottom="5dp" 
     android:paddingTop="5dp" 
     android:layout_marginTop="16dp"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="With normal WebView" 
      android:textColor="@color/colorAccent" /> 

    </LinearLayout> 

</RelativeLayout> 

레이아웃은 기본 Acitvity입니다, 그것은 CoordinatorLayout 내에서 의미합니다.

XWalkView 초기화 :

public class GenerateActivity extends AppCompatActivity { 

    Snackbar snackbar; 
    View snackView; 
    XWalkView lWebView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_generate); 

     // Toolbar 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     if(toolbar != null) { 
      setSupportActionBar(toolbar); 
      getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
      toolbar.setNavigationOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        onBackPressed(); 
       } 
      }); 
     } 

     initWebView(); 

     // Snackbar Code... 

    } 

    private void initWebView() { 
     lWebView = (XWalkView) findViewById(R.id.webView); 

     lWebView.clearCache(true); 
     File lFile = new File("android_asset/index.html"); 

     XWalkPreferences.setValue("enable-javascript", true); 
     XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, false); 

     lWebView.load("file:///" + lFile.getAbsolutePath(), null); 
    } 

} 

종속성 :

compile 'org.xwalk:xwalk_core_library:22.52.561.4' 

누군가가 알고 있나요은 왜, 어떻게 그것을 해결하기 위해인가?

감사합니다. // 편집

나는 해결 방법을 발견했다. 모든 것 아래에 1dp 패딩을 추가하면 ... XWalkView를 새로운 프로젝트에서 같은 방식으로 시도해 본 결과 같은 문제가 발생했습니다. 아마 그것은 도서관의 문제 일 것입니다.

당신이 활동에 XWalkView을 받고 있지만, 당신은 몇 가지 지식을 얻을 수에서 내가 예를 게시하고 어떻게 당신은에 대한 더 많은 정보를 제공하지 않았다

답변

0

: 당신은 추가해야 gradle 파일에서

import android.app.Activity; 
    import android.os.Bundle; 

    import org.xwalk.core.XWalkResourceClient; 
    import org.xwalk.core.XWalkUIClient; 
    import org.xwalk.core.XWalkView; 

    public class MyActivity extends Activity { 
     XWalkView mXwalkView; 

     class MyResourceClient extends XWalkResourceClient { 
      MyResourceClient(XWalkView view) { 
       super(view); 
      } 

      @Override 
      WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) { 
       // Handle it here. 
       ... 
      } 
     } 

     class MyUIClient extends XWalkUIClient { 
      MyUIClient(XWalkView view) { 
       super(view); 
      } 

      @Override 
      void onFullscreenToggled(XWalkView view, String url) { 
       // Handle it here. 
       ... 
      } 
     } 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      mXwalkView = new XWalkView(this, null); 
      setContentView(mXwalkView); 
      mXwalkView.setResourceClient(new MyResourceClient(mXwalkView)); 
      mXwalkView.setUIClient(new MyUIClient(mXwalkView)); 
      mXwalkView.load("http://www.google.com", null); 
     } 

     @Override 
     protected void onPause() { 
      super.onPause(); 
      if (mXwalkView != null) { 
       mXwalkView.pauseTimers(); 
       mXwalkView.onHide(); 
      } 
     } 

     @Override 
     protected void onResume() { 
      super.onResume(); 
      if (mXwalkView != null) { 
       mXwalkView.resumeTimers(); 
       mXwalkView.onShow(); 
      } 
     } 

     @Override 
     protected void onDestroy() { 
      super.onDestroy(); 
      if (mXwalkView != null) { 
       mXwalkView.onDestroy(); 
      } 
     } 

     @Override 
     protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
      if (mXwalkView != null) { 
       mXwalkView.onActivityResult(requestCode, resultCode, data); 
      } 
     } 

     @Override 
     protected void onNewIntent(Intent intent) { 
      if (mXwalkView != null) { 
       mXwalkView.onNewIntent(intent); 
      } 
     } 
    } 

을 종속 좋아 : 더 자세한 내용은

compile 'org.xwalk:xwalk_core_library:10.39.235.15' 
+0

, 당신은 참조 할 수 있습니다 :은 https : //github.com/crosswalk-project/crosswalk/pull/3857/files –

+0

이봐 당신의 응답을 주셔서 감사합니다. 하지만 초기화 문제라고 생각하지 않습니다. 언급 한 바와 같이 문제없이 동일한 응용 프로그램의 조각에서 XwalkView를 사용하고 있습니다. 나는 또한 같은 초기화를 사용했다. – Fintasys

+0

그러나 위의 코드를 추가했습니다. 고맙습니다! – Fintasys