如何正确设置浮动操作按钮? [英] How to set Floating Action Button correctly?
问题描述
我有一个问题。我用这个这个库,使向上滑动面板。点击这里。我说,然后我试图让漂浮的动作按钮,在谷歌地图应用程序(如照片)。
I have a problem. I used this this library to make sliding up panel. Click here. I added it and then I tried to make floating action button as in google map application.(As in the picture).
但在这里我下面的结果。如何设置(使滑动面板达拉斯奥斯preNT可能是顶部)它正确,如1-ST图片。
But here below my result. How to set (make top of sliding panel trasprent may be) it correctly as in 1-st picture.
fragment_1.xml (查看滑动布局的一部分)
fragment_1.xml (Check out Sliding layout part)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="56dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParalaxOffset="50dp"
sothree:umanoDragView="@+id/dragView"
xmlns:fab="http://schemas.android.com/apk/res-auto">
<!-- MAIN CONTENT -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
</LinearLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="390dp"
android:background="@android:color/transparent"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
sothree:umanoOverlay="true"
android:layout_below="@+id/main_content">
<!-—TOP OF PANEL -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="#03A9F4"
android:id="@+id/dragView">
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textColor="@android:color/white"/>
<Button
android:id="@+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:gravity="center_vertical|right"
android:paddingRight="10dp"
android:paddingLeft="10dp"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
sothree:fab_type="normal"
android:layout_marginBottom="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right|center"
android:tint="@android:color/white"
android:src="@android:drawable/ic_dialog_map"
fab:fab_colorNormal="@color/fab_primary"
fab:fab_colorPressed="@color/fab_pressed"
fab:fab_colorRipple="@color/fab_ripple"/>
</LinearLayout>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
感谢您的帮助!
Thanks for any help!
推荐答案
把&LT; com.melnykov.fab.FloatingActionButton /&GT;
的<$ C $外C>&LT; com.sothree.slidinguppanel.SlidingUpPanelLayout /&GT; ,不要忘记用marginTop和marginLeft找到它:
put the <com.melnykov.fab.FloatingActionButton/>
outside the <com.sothree.slidinguppanel.SlidingUpPanelLayout/>
and don't forget to locate it by using marginTop and marginLeft:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="56dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParalaxOffset="50dp"
sothree:umanoDragView="@+id/dragView"
xmlns:fab="http://schemas.android.com/apk/res-auto">
<!-- MAIN CONTENT -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
</LinearLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="390dp"
android:background="@android:color/transparent"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
sothree:umanoOverlay="true"
android:layout_below="@+id/main_content">
<!--—TOP OF PANEL -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="#03A9F4"
android:id="@+id/dragView">
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textColor="@android:color/white"/>
<Button
android:id="@+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:gravity="center_vertical|right"
android:paddingRight="10dp"
android:paddingLeft="10dp"/>
</LinearLayout>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
sothree:fab_type="normal"
android:layout_marginBottom="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right|center"
android:tint="@android:color/white"
android:src="@android:drawable/ic_dialog_map"
android:layout_marginLeft="300dp"
android:layout_marginTop="200dp"
fab:fab_colorNormal="@color/fab_primary"
fab:fab_colorPressed="@color/fab_pressed"
fab:fab_colorRipple="@color/fab_ripple"/>
</RelativeLayout>
这篇关于如何正确设置浮动操作按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!