मुझे FAB FAB को Fragment के अंदर रखने में समस्या है। एफएबी ऊपर, बाएं है, लेकिन मुझे उन्हें नीचे, दाएं की जरूरत है।
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.vrhcaby.VrhcabyFragment">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:src="@mipmap/dice_180"
android:layout_margin="100px" />
<com.google.android.material.floatingactionbutton.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:srcCompat="@android:drawable/ic_dialog_email" />
</RelativeLayout>
मेरे पास क्या गलत है?
1
Jodynek
20 सितंबर 2021, 17:26
2 जवाब
सबसे बढ़िया उत्तर
जैसा कि मैंने पढ़ा है, एफएबी सापेक्ष लेआउट के साथ बहुत अच्छी तरह से काम नहीं करता है और आपको इसके बजाय समन्वयक लेआउट का उपयोग करना चाहिए।
- सबसे पहले इसकी निर्भरता को build.gradle (मॉड्यूल: ऐप) में शामिल करें
dependencies {
...
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
...
}
- फिर सापेक्ष लेआउट के बजाय समन्वयक लेआउट को इस तरह घोषित करें
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.vrhcaby.VrhcabyFragment">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:src="@mipmap/dice_180"
android:layout_margin="100px" />
<com.google.android.material.floatingactionbutton.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:srcCompat="@android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
यदि आप अधिक जानकारी चाहते हैं तो आप एफएबी के बारे में अधिक पढ़ सकते हैं यहां< /ए>
0
Omar Shawky
20 सितंबर 2021, 17:49
सापेक्ष लेआउट फैब का समर्थन नहीं करता है जबकि समन्वयक लेआउट करता है। आप ऐसा कुछ कर सकते हैं।
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/ivPic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/badimalika"
android:scaleType="centerCrop"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_dialog_email"
app:layout_anchorGravity="bottom|end"
app:layout_anchor="@id/ivPic"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
0
Rudra Rokaya
20 सितंबर 2021, 17:54
संबंधित सवाल
नए सवाल
java
जावा एक उच्च स्तरीय प्रोग्रामिंग भाषा है। इस टैग का उपयोग तब करें जब आपको भाषा का उपयोग करने या समझने में समस्या हो। इस टैग का उपयोग शायद ही कभी किया जाता है और इसका उपयोग अक्सर [वसंत], [वसंत-बूट], [जकार्ता-ई], [Android], [javafx], [हडूप], [श्रेणी] और [मावेन] के साथ किया जाता है।