Sunday, September 28, 2014

How to Open Java Images in Android

Instructions

    1

    Open the Eclipse software on your desktop and open the Android app project to open all of the files in the editor.

    2

    Double-click the "main.xml" file in the "resource" directory. This file is where you place your XML images and layout. Add the following code to add an image to the app:

      android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">

      android:background="@null"
    android:id="@+id/myimage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/myimage" />

    The "myimage" ID is the image you want to use from the list of Java project images.

    3

    Open the view and display the image in your app. The following code opens the "main.xml" file and displays the image:

    setContentView(R.layout.main);



No comments:

Post a Comment