我有一个背景的活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px"
android:background="@drawable/background_fingerboard" />
如何更改背景图片从code?实际上我用单声道,而且Java的样品也将是有帮助的。
How can I change background image from code? I actually use mono, but Java samples will also be helpful.
先添加的LinearLayout ID作为在布局的xml:
first add LinearLayout id as in your layout xml:
<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_fingerboard"
在code部分集背景::
and in code part set background as::
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearLayoutid);
linearLayout.setBackgroundResource(R.drawable.background_fingerboard);
上一篇:getActivity()在FragmentActivity:机器人机器人、getActivity、FragmentActivity
下一篇:overridePendingTransition只显示进入动画只显示、动画、overridePendingTransition