我试图让FAB超过recyclerview,在我的情况下将覆盖整个屏幕.FAB不会显示甚至recyclerview是空的.以下是我的xml代码.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.technistan.ledger.CreateLedger"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
></include>
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:id="@+id/recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="20dp"
app:elevation="4dp" />
</FrameLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
android:name="com.technistan.ledger.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
预览显示浮动按钮,如下图所示; https://www.dropbox.com/s/18u5pt5v6kkkibj/Screen%20Shot%202015-09-13%20at%201.19.20%20PM.png?dl=0
但是当我运行应用程序时,没有显示FAB.我曾尝试过很多种组合,但都没能成功.我在listview上尝试了这个没有navigationdrawer(简单的活动,它在那里工作,即在listview上显示).
任何帮助将不胜感激.谢谢
[编辑:]我认为问题是由于父布局,即android.support.v4.widget.DrawerLayout,我复制粘贴代码从开始到结束到另一个空活动,它显示浮动按钮在那里.但仍然无法弄清楚如何解决这个问题,我需要在Drawerlayout中显示浮动操作按钮.
我在两个模拟器api 23和api 19上运行我的应用程序.当我在api 19中单击EditText时,没有显示软键盘,而它在api 23上正常工作.我的布局文件中可能存在一些问题,如下所示.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.technistan.ledger.NewLedger">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
></include>
<LinearLayout
android:paddingLeft="20dp"
android:paddingRight="32dp"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_below="@id/tool_bar"
android:orientation="vertical"
android:id="@+id/linearlayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:id="@+id/spinner_category"
android:layout_width="232dp"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btnR"
android:background="@color/primary"
android:layout_marginLeft="15dp"
android:layout_marginTop="8dp"
android:textColor="@color/icons"
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:id="@+id/layoutReveal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<EditText
android:id="@+id/etLedgerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Enter Ledger Name"/>
<EditText
android:id="@+id/etCurrencySign"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Enter Current Type (e.g USD, $, PKR)"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_below="@id/linearlayout1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<LinearLayout …Run Code Online (Sandbox Code Playgroud)