作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是我的activity_splash.xml布局和manifest.xml。当我在 java 代码中使用 setContentView(R.layout.activity_splash) 时,它给我错误(activity_splash 无法解析或它不是一个字段
)。 R.java 中没有对此 xml 文件的引用。我的代码有问题吗。我只做了两处更改,之后就出现了这个错误。这就是我在这里发布这两个文件的原因。我想做的是在应用程序启动时通过显示闪屏来加载 web View 中的 URL。
activity_splash.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff0000 >
<ImageView
android:id="@+id/imgLogo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/nricabs"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="22sp"
android:layout_alignParentBottom="true"
android:text="@string/url" />
</RelativeLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.browser"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/nricabs"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
//activity_splash.xml is used in seperate SplashScreen.java file
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:name=".SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
以及如何在显示闪屏的同时实现 webview 背景中的 url 加载。我的方法正确吗?
最佳答案
试试这个,
下一行中缺少“(双引号)。
android:background="#ffff0000"
以下是您编辑的xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff0000" >
<ImageView
android:id="@+id/imgLogo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/nricabs"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="22sp"
android:layout_alignParentBottom="true"
android:text="@string/url" />
</RelativeLayout>
关于java - Activity_splash 无法解析或者它不是 Android 应用程序中的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32821866/
下面是我的activity_splash.xml布局和manifest.xml。当我在 java 代码中使用 setContentView(R.layout.activity_splash) 时,它给
我是一名优秀的程序员,十分优秀!