当我尝试构建应用程序时,它将在FloatingActionButton中显示"@cycle/dom": "^12.2.5"
"@cycle/http": "^11.0.1"
"@cycle/xstream-run": "^3.1.0"
"xstream": "^6.4.0"
?我真的不知道导致错误的原因。
Login.xml
android.view.InflateException
styles.xml
<?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"
android:background="@drawable/bg_image" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/lLayout_logincontainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="40dp"
android:orientation="vertical">
<ImageView
android:layout_width="130dp"
android:layout_height="125dp"
android:src="@drawable/project"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<EditText
android:id="@+id/aTxt_UserName"
style="@style/edittextstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="User Name"
android:imeOptions="actionNext"
android:textColorHint="@color/white"
>
</EditText>
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/eTxt_PassWord"
style="@style/edittextstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:textColorHint="@color/white"
android:textColor="@color/white" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="3dp"
android:background="@drawable/button_shape"
android:padding="12dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_gravity="bottom|end"
android:layout_marginRight="@dimen/fab_margin"
android:visibility="visible"
app:backgroundTint="@color/colorTrade_2"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:fabSize="normal"
app:rippleColor="@android:color/transparent"
android:src="@drawable/ic_user_add" />
</android.support.design.widget.CoordinatorLayout>
的AndroidManifest.xml
<resources>
<style name="AppBaseTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:itemBackground">@color/white</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">12sp</item>
<item name="textAllCaps">false</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="edittextstyle">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">14sp</item>
<item name="android:padding">10dp</item>
<item name="android:singleLine">true</item>
<item name="android:textColorHint">@color/white</item>
<item name="android:inputType">textFilter</item>
</style>
<style name="userProfileText">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">14sp</item>
<item name="android:padding">5dp</item>
</style>
</resources>
的build.gradle
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android" package="com.trade.seems">
<uses-library android:name="com.google.android.maps" android:required="true" />
<application android:allowBackup="true"
android:name=".utils.MyApplication"
android:isolatedProcess="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:largeHeap="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="@string/google_api_key" />
<activity android:name=".uil.SplashActivity"
android:screenOrientation="sensorPortrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ual.login.LoginActivity"
android:screenOrientation="sensorPortrait"/>
</application>
</manifest>
完成错误跟踪
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.trade.seems"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/maven/ch.acra/acra/pom.xml'
exclude 'META-INF/maven/ch.acra/acra/pom.properties'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
dexOptions {
javaMaxHeapSize "2g"
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile files('libs/picasso-2.5.2.jar')
compile files('libs/httpclient-4.3.6.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
/*Support Libraries */
compile project(':autocomplete_library')
compile project(':ViewPagerIndicator-Library')
/*Third party Libraries */
compile 'es.guiguegon:gallerymodule:1.3.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.makeramen:roundedimageview:2.0.1'
//Library to handle Material design for all Version of android
compile 'com.rengwuxian.materialedittext:library:2.1.4'
//Library Glide is to handle Images Instead of picasso
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
/*Google Android Support Library*/
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
答案 0 :(得分:13)
在你的案例中,问题在你的styles.xml中,你的基本主题名是AppBaseTheme。将其更改为AppTheme,因为您可以看到您在Mainfest文件中使用了AppTheme。
我列出了可能导致类android.support.design.widget.FloatingActionButton的所有原因。请仔细阅读要点。
FAB按钮是Design Library Cpmponent。您的活动必须扩展 AppCompatActivity ,而不是活动。
您的活动主题也应该是适当的 Theme.AppCompat 主题。 FAB也需要colorAccent。确保在styles.xml中包含它们。
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.AppTheme">
<!-- Customize your theme here. -->
</style>
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
使用 app:backgroundTint =“@ color / your_color”而不是android:backgroundTint。
不要错过在项目build.gradle文件中添加设计库
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
...
}
在Extras中更新SDK Manager上的支持库&gt; Android支持存储库和Android支持库
希望它能解决你的错误。
答案 1 :(得分:2)
如果您在API 21+上使用backgroundTint
,那么
只需在FloatingActionButton中使用此行(app
而不是android
):
app:backgroundTint="@color/colorAccent"
以下是示例布局
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:elevation="6dp"
android:tint="#FFF"
app:srcCompat="@drawable/ic_add_black_24dp" />
</android.support.design.widget.CoordinatorLayout>