2017-07-26 6 views
2

私はfabで他のプロジェクトにフローティングアクションボタンを実装してカスタマイズしても問題ありません。しかし今度は、私のXMLレイアウトでfabオブジェクトを作成すると、エラーが表示されます。混乱していると、そのタグの一部を削除しようとしました。アンドロイド:backgroundTintタグを指定すると、エラーが表示されることがわかりました。ここで背景色の浮動アクションボタンでエラーが発生する

コードです:ここでは

<android.support.design.widget.FloatingActionButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:fabSize="mini" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:src="@drawable/ic_action_fab" 
    android:backgroundTint="#2196F3" 
    android:layout_margin="12dp"/> 

は私のビルドです:

compileSdkVersion 25 
buildToolsVersion '25.0.0' 

defaultConfig { 
    applicationId "com.xxxx.xxxx" 
    minSdkVersion 10 
    targetSdkVersion 23 
    versionCode 1 
    versionName "2.0.4" 
} 

私はまた、GoogleのデザインのGradleを追加しました。

エラー:できるだけ早く私はアンドロイド取り除くよう

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxx.xxxx/com.xxxx.xxxx.HomeActivity}: android.view.InflateException: Binary XML file line #141: Binary XML file line #141: Error inflating class android.support.design.widget.FloatingActionButton 

:backgroundtintタグを、エラーがなくなっています。なぜこれが起こっているのか?

答えて

6

代わりのandroid:backgroundTint="#2196F3"app:backgroundTint="#2196F3"

3

と 試みは、documentationによると、デフォルトでは、のstyles.xml属性colorAccentに設定された色になります。あなたは色を変更したい場合は、属性app:backgroundTint なくandroid:backgroundTint

とXMLでそうファブアイコンのための最終的なXMLは、上記の答えとして

<android.support.design.widget.FloatingActionButton 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
app:fabSize="mini" 
android:layout_alignParentBottom="true" 
android:layout_alignParentRight="true" 
android:src="@drawable/ic_action_fab" 
app:backgroundTint="#2196F3" 
android:layout_margin="12dp"/> 
0

なります

、それはandroid:backgroundTintの代わりにapp:backgroundTintを追加するのは正しいです。あなたはこれにこれの詳細を見つけることができますanswer

私はそれが重複のようなかもしれないので、私はこの投稿を削除する必要が本当にわからないが、私は本当にあなたの助けの人に感謝します。

関連する問題