我在我的应用程序中使用片段,我必须更改FragmnetTabs中的片段之一的背景。出于这个原因,我在该片段的布局中设置了background
,我可以看到Eclipse
的Graphical Layout
工作正常。但是当我运行我的应用程序时,它显示了黑色背景的碎片内容,而不是我设置的图像。我是这样设置的…
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >
<RelativeLayout/>
但是这个绘图没有显示在应用程序中。有什么问题吗?任何帮助都是感激的。谢谢!
编辑:如果我尝试按以下方式设置背景,它会很好。
android:background="@drawable:color/anycolor"
为什么自定义图像不显示,但android的颜色呢?
您可以尝试在代码中执行此操作。Call on your RelativeLayout
yourRelativeLayout.setBackground(getActivity().getResources().getDrawable(R.drawable.YourImage));