I was using XWalkView before in a Fragment with overlay Views in RL.
Now I wanted to use it in an Acitvity, but I get Layout rendering problems and Snackbar isn't working anymore.
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>
The Layout is a Basic Acitvity, that means it's within a CoordinatorLayout.
XWalkView Initialization:
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);
}
}
Dependency:
compile 'org.xwalk:xwalk_core_library:22.52.561.4'
Does somebody know's why and how to fix it?
Thank you!
// EDIT
I found a workaround. By adding 1dp padding below everything is fine... I tried XWalkView the same way in a new project and got the same problem. Maybe It's a problem of the library.
You did not give the much more information about, how you are getting your
XWalkView
in activity but i am posting an example from that You can get some knowledge:In
gradle
file you have to add dependencies like: