TheFinestArtist / FinestWebView-Android

Beautiful and customizable Android Activity that shows web pages within an app.
https://finestwebview.web.app
2.32k stars 531 forks source link

Couldn't resolve resource @id/centerLayout #85

Closed digitalprecision closed 8 years ago

digitalprecision commented 8 years ago

I am trying to implement a single page webview via your api and keep running into the "Couldn't resolve resource @id/centerLayout" error.

I took a look at your sample code and it works, but I try to do a single view it doesn't work. What I did is remove the webview references and put everything relevant into main references so WebView.xml and Webview.java were deleted.

Here's what I have in MainActivity.java:

package com.myproduct.mothership;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import com.thefinestartist.finestwebview.FinestWebView;

public class MainActivity extends AppCompatActivity {

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

        new FinestWebView.Builder(this)
                .webViewJavaScriptEnabled(true)
                .show("https://mywebsite.com");
    }
}

Then in main.xml I have:

<?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:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/finestWhite"
    tools:context=".MainActivity"
    >

    <FrameLayout
        android:id="@+id/webLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
    </FrameLayout>

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp"
        >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:padding="0dp"
            app:contentInsetEnd="0dp"
            app:contentInsetLeft="0dp"
            app:contentInsetRight="0dp"
            app:contentInsetStart="0dp"
            app:layout_scrollFlags="scroll|enterAlways"
            >

            <include layout="@layout/toolbar_content"/>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>

    <View
        android:id="@+id/gradient"
        android:layout_width="match_parent"
        android:layout_height="@dimen/defaultDividerHeight"
        android:layout_marginTop="@dimen/toolbarHeight"
        android:background="@color/finestBlack10" 
    />

    <ProgressBar
        android:id="@+id/progressBar"
       android:layout_width="match_parent"
        android:layout_height="@dimen/defaultProgressBarHeight"
        android:layout_marginTop="@dimen/toolbarHeight"
        android:indeterminate="false"
        android:progressDrawable="@drawable/progress_drawable"
        style="?android:attr/progressBarStyleHorizontal"
        />

    <include layout="@layout/menus"/>

</android.support.design.widget.CoordinatorLayout>

And finally in my AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myproduct.mothership">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity
            android:name="com.thefinestartist.finestwebview.FinestWebViewActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="sensor"
            android:theme="@style/FinestWebViewTheme.Fullscreen" />

    </application>

</manifest>
digitalprecision commented 8 years ago

Closing issue, I was able to resolve by removing the empty frame from the stack.