Reputation: 5826
Im having issues with the toolbar being display ontop of the webview and i am trying to figure out how to remedy this. Any and all feedback is greatly appreciated.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context="com.example.ui.activities.WebActivity">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_web" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipe_refresh">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webview" />
</android.support.v4.widget.SwipeRefreshLayout>
Here some code regarding how i am setting up the webview.
public class WebActivity extends BaseActivity {
@Bind(R.id.webview)
WebView webView;
@Bind(R.id.toolbar)
Toolbar toolbar;
@Bind(R.id.swipe_refresh)
public SwipeRefreshLayout swipeRefreshLayout;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
setSupportActionBar(toolbar);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
webView.reload();
}
});
if (savedInstanceState == null) {
webViewUrl = AUTH_URL;
runOnUiThread(new Runnable() {
@Override
public void run() {
webView = initWebView();
webView.loadUrl(webViewUrl);
}
});
} else {
webViewUrl = savedInstanceState.getString(KEY_URL,AUTH_URL);
runOnUiThread(new Runnable() {
@Override
public void run() {
webView.loadUrl(webViewUrl);
}
});
}
}
}
Any and all help will be very appreciated.
Upvotes: 1
Views: 1583
Reputation: 8938
Layouts in a CoordinatorLayout
need to define a layout_behavior
. Change your content to this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipe_refresh"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webview" />
</android.support.v4.widget.SwipeRefreshLayout>
Upvotes: 1