2015-12-27 31 views
0

可见这是我在列表视图布局XML文件中的代码按钮在模拟器的ListView不可见的,虽然它是在渲染

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:id="@android:id/empty" 
     android:text="No schedules available" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </TextView> 

    <ListView android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:drawSelectorOnTop="false" 
     android:layout_gravity="right|bottom" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <ImageButton 
     android:layout_width="89dp" 
     android:layout_height="56dp" 
     android:id="@+id/add_schedule" 
     android:layout_gravity="right" 
     android:src="@mipmap/ic_add_fab" 
     android:background="#00ffffff" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 


    </RelativeLayout> 

按钮是在渲染器,但不是在我的模拟器可见。 Suggesstions会很有帮助 这整个设置是在一个主详细流程

+1

做任何事情,我会建议在此之前,您在真实设备中检查您的代码,因为图形渲染器和模拟器中的外观可能会引起误解。作为一个便笺,您是否使用Android Studio? – drWisdom

+0

是的,我正在使用android studio –

+0

我认为你正在设置图像按钮作为浮动操作按钮(FAB)。在这种情况下,您可能会更好地使用官方FAB小部件,而不是创建自己的。这是完成作为它会简化你的过程,并最大限度地减少奇怪的行为 – drWisdom

回答

1

首先,您的按钮显示在模拟器,但你没有看到它,因为它可能隐藏在ListView下。

你会说:

“我ListView是在RelativeLayout左下角”。

部分你是对的,但看 - 你设置的宽度为match_parent。改变这个属性让我们假设30dp,我相信你会看到你的按钮。

尝试其他人的建议Floating Action ButtonFAB)。这里有一个很好的教程如何正确地使用它:https://guides.codepath.com/android/floating-action-buttons

如果你不喜欢的标准执行的话,看看这个页面: https://android-arsenal.com/tag/173

希望它能帮助

+0

感谢您的写作...试图改变宽度和高度,但列表填补父母即使那样。 –

+0

如果你真的需要这个按钮寻找如何把它放在布局或使用FAB – piotrek1543

+0

即使工厂在android studio预览呈现,但我不能看到它在模拟器 –

相关问题