I'm trying to decrease FAB
margins on pre-Lollipop devices but whatever I do - nothing changes. I create two FAB
s one is in the right|end|bottom
other is up to the previous. That 16dp
margins make a distance between two FAB
s for 32dp
and this is too large for me. If to use bottop_padding
down button's clickable area overlapping the second button. Maybe, somebody had the same problem? Please, help me!
here is picture of how it looks like
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/directions"
app:backgroundTint="@android:color/holo_blue_light"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_above="@+id/uer_position"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_location"
app:backgroundTint="@android:color/white"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
On pre-lollipop, margins are automatically added to the FAB
s. Create a new folder named values-v21
and create a xml
file named dimes.xml
and add the following line
<dimen name="btn_fab_margins">16dp</dimen>
Then go to your dimens.xml
in your values
folder and add the following
<dimen name="btn_fab_margins">0dp</dimen>
Now in your layout add following to the FABs
android:layout_margin="@dimen/btn_fab_margins"
The problem will be solved. as with pre-lollipop it will take the 0dp
margin and with lollipop it take the 16dp
margin.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.