Imageview used to display image.
Note: Below code is verified with Android 4.0.3 emulator.
activity_image_view_example.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/ivfirst"
android:layout_height="match_parent"
android:layout_width ="match_parent"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/ivfirst"
/>
</LinearLayout>
strings.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/ivfirst"
android:layout_height="match_parent"
android:layout_width ="match_parent"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/ivfirst"
/>
</LinearLayout>
ImageViewExample.java
package com.example.testexample;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class ImageViewExample extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view_example);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_image_view_example, menu);
return true;
}
}
Note: Below code is verified with Android 4.0.3 emulator.
activity_image_view_example.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/ivfirst"
android:layout_height="match_parent"
android:layout_width ="match_parent"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/ivfirst"
/>
</LinearLayout>
strings.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/ivfirst"
android:layout_height="match_parent"
android:layout_width ="match_parent"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/ivfirst"
/>
</LinearLayout>
ImageViewExample.java
package com.example.testexample;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class ImageViewExample extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view_example);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_image_view_example, menu);
return true;
}
}
Result:
No comments:
Post a Comment