2016-10-11 20 views
0

2ヶ月前からAndroidスタジオを学校に使い始めました。私はFloatinActionButtonにいくつか問題があります。私はサポートライブラリを使用していますが、KitKatには表示されません。FloatingActionButtonがKitKatに表示されない

これは何を私の活動のXMLです:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
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/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.leonardoguerrag.budget.MainActivity" 
android:clipToPadding="true" 
android:paddingBottom="0dp" 
android:background="@android:color/holo_orange_light"> 

<android.support.design.widget.FloatingActionButton 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:clickable="true" 
app:fabSize="mini" 
app:srcCompat="@android:drawable/ic_menu_compass" 
android:id="@+id/btnAgregarGasto" 
app:layout_constraintBottom_toTopOf="@+id/btnAgregar" 
android:layout_marginBottom="16dp" 
app:layout_constraintLeft_toLeftOf="@+id/btnAgregar" 
app:layout_constraintRight_toRightOf="@+id/btnAgregar" /> 

<android.support.design.widget.FloatingActionButton 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:clickable="true" 
app:fabSize="mini" 
app:srcCompat="@android:drawable/ic_input_get" 
android:id="@+id/btnAgregarBudget" 
app:backgroundTint="?attr/colorPrimary" 
app:layout_constraintBottom_toTopOf="@+id/btnAgregarGasto" 
android:layout_marginBottom="16dp" 
app:layout_constraintLeft_toLeftOf="@+id/btnAgregarGasto" 
app:layout_constraintRight_toRightOf="@+id/btnAgregarGasto" /> 

<android.support.design.widget.FloatingActionButton 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:clickable="true" 
app:fabSize="normal" 
app:srcCompat="@android:drawable/ic_input_add" 
android:id="@+id/btnAgregar" 
app:backgroundTint="@android:color/holo_blue_dark" 
app:layout_constraintBottom_toBottomOf="@+id/viewPager" 
android:layout_marginBottom="16dp" 
app:layout_constraintRight_toRightOf="@+id/viewPager" 
android:layout_marginEnd="16dp" 
android:layout_marginRight="16dp" /> 

<android.support.design.widget.TabLayout 
android:layout_width="0dp" 
android:layout_height="wrap_content" 
app:tabMode="fixed" 
android:id="@+id/tabLayout" 
app:layout_constraintTop_toTopOf="parent" 
app:layout_constraintLeft_toLeftOf="parent" 
app:layout_constraintRight_toRightOf="parent"> 
</android.support.design.widget.TabLayout> 

<android.support.v4.view.ViewPager 
android:layout_width="0dp" 
android:id="@+id/viewPager" 
android:layout_height="0dp" 
app:layout_constraintTop_toBottomOf="@+id/tabLayout" 
app:layout_constraintLeft_toLeftOf="parent" 
app:layout_constraintRight_toRightOf="parent" 
app:layout_constraintBottom_toBottomOf="parent" 
app:layout_constraintHorizontal_bias="0.0" 
app:layout_constraintVertical_bias="0.0">  
</android.support.v4.view.ViewPager> 

私の依存関係:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' 
    compile 'com.android.support:cardview-v7:24.2.1' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.android.support:recyclerview-v7:24.2.1' 
} 

マシュマロ及びヌガーに意図したとおりそれはおそらくロリポップで、動作します。

私は何が欠けているのか分かりません。

thisを調べましたが、回答が見つかりませんでした。

ありがとうございます!

+0

ここで、xmlにはコードの最初のブロックがありますか?また、 'FloatingActionButton'を含むコンテナの階層は何ですか? –

+0

こんにちは!私は自分の質問を編集し、XML全体を追加しました。私は "新しい" ConstraintLayoutを使用しています(私の教授は次の試験に行くと言っていたので、私は練習していました) 私の悪い英語のために申し訳ありません! – LeonardoGuerraG

+0

私はxmlの最後にそれを置こうとします。それを 'ConstraintLayout'の中でまだ最後の要素にしてください –

答えて

0

どういうわけか、ボタンは正しく表示されますが、ViewPagerの背面に表示されます。

私のonCreate()関数では、ちょうど.bringToFront()を追加しました。すべての私のFABで、彼らは今見えている!

Ex。

FloatingActionButton btnAgregar; 
btnAgregar = (FloatingActionButton) findViewById(R.id.btnAgregar); 
btnAgregar.bringToFront(); 
0

Kitkat以前はレイアウトに奇妙なものがありますが、重要ではないという要素がある場合でも、時々あなたのXMLを順番にレイアウトします。したがって、プログラムでもフォアグラウンドでも、最後にxmlを入れてみてください。

関連する問題