Android 为片段设置背景?
我在应用程序中使用片段,我必须更改FragmnetTabs中一个片段的背景。正是由于这个原因,我在fragmnet的布局中设置了Android 为片段设置背景?,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我在应用程序中使用片段,我必须更改FragmnetTabs中一个片段的背景。正是由于这个原因,我在fragmnet的布局中设置了背景,我可以在Eclipse的图形布局中看到它工作正常。但当我运行应用程序时,它会显示黑色背景的内容片段,而不是我设置的图像。我是这样设置的 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.andr
背景
,我可以在Eclipse的图形布局
中看到它工作正常。但当我运行应用程序时,它会显示黑色背景的内容片段,而不是我设置的图像。我是这样设置的
<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 Color会显示?您可以在代码中尝试这样做。请访问您的RelativeLayout
yourRelativeLayout.setBackground(getActivity().getResources().getDrawable(R.drawable.YourImage))代码>@Marco该xml与我发布的相同。我的意思是它不完整…但它的主要布局在屏幕上。
android:background="@drawable:color/anycolor"