Я пытаюсь отобразить главный экран изнутри с помощью setContentView (R.layout.main); а потом изображение отображается следующим образом:Android View Help
общественный класс TryGraph расширяет активность {
/** Called when the activity is first created. */
public LinearLayout mLinearLayout;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create a LinearLayout in which to add the ImageView
mLinearLayout = new LinearLayout(this);
// Instantiate an ImageView and define its properties
ImageView i = new ImageView(this);
i.setImageResource(R.drawable.face3);
i.setAdjustViewBounds(true); // set the ImageView bounds to match the Drawable's dimensions
mLinearLayout.addView(i);
setContentView(mLinearLayout);
}
}
main.xml подобно этому
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="button" android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
кнопка скрыта по рисунку, поскольку он нарисован поверх кнопки. Как разместить рис на лету в разных местах, чтобы отображались как кнопка, так и рис. note: Я не хочу отображать pic из xml, я хочу отобразить его из LinearLayout.
http://stackoverflow.com/questions/3442331/draw-view-on-image-within-xml –