我在drawable上有文件bacground_im.png。 当我在Activity_main.xml更改背景时出错。
如何解决问题?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="@drawable/background_im">
答案 0 :(得分:0)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/linearLayoutid"
android:minWidth="25px"
android:minHeight="25px"
android:background="@drawable/
background_im"
并在代码部分中将背景设置为::
LinearLayout linearLayout =
(LinearLayout)
findViewById(R.id.linearLayoutid);
linearLayout.setBackgroundResource
(R.drawable.background_im);