Hi I created one medical app. it,s working fine. i placed one logo in center of the app screen my logo size height and width is 70x70 and my emulator screen resolution is 900 x 800 if i change my screen resolution i wish to change my logo size also dynamic. this is my doubt how to set logo depending upon the screen resolution?
code:
public class ImageviewAppActivity extends Activity {
private ImageView img;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img =(ImageView) findViewById(R.id.imagetest);
img.setMaxWidth(20);
img.setMaxHeight(100);
}
}
xml: main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imagetest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Look,I think you should set size of logog according to diffrent resolution then try to use
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
float density = metrics.density;
density is float and its value changed as per screen size...
so,if you have
240*320 density is 0.5
320*480 density is 1.0
480*800 density is 1.5
and set size using density like , img.setMaxHeight(density*100);
and also put multiple screen supports in manifest file...Multiple Screen Support