В моем приложении, когда я нажимал кнопку, я должен был перейти на новую страницу, и она показывает изображение. Размер изображения: ширина 480 пикселей и высота 1257 пикселей . Изображение очень четкое в ландшафтном режиме, где, как и в портретном режиме, оно кажется растянутым. но мне нужно быть идеальным с обеих сторон.
Следующим является код xml
<?xml version="1.0" encoding="UTF-8"?>
<AbsoluteLayout
android:id="@+id/finalPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content"
android:layout_height="30px"
android:orientation="vertical"
>
<ImageView
android:id="@+id/widget41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="0px"
>
</ImageView>
</LinearLayout>>
</ScrollView>>
</AbsoluteLayout>
это должно быть частью моего исходного кода
public class HelpPage extends Activity
{
ImageView BackGroundImage;
int width,height,orientation;
// ImageView help;
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
setContentView(R.layout.help);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
WebView webview;
webview = (WebView) findViewById(R.id.webview);
// webview.loadUrl("file:///android_asset/helptext.html");
Log.e("FirstImage", "Width = "+width+"Height = "+height+" orientation= "+orientation);
BackGroundImage = (ImageView) findViewById(R.id.widget41);
BackGroundImage.setBackgroundResource(R.drawable.help);
if(width == 320 && height == 480)
{
BackGroundImage.setBackgroundResource(R.drawable.help);
}
//Landscape mode of 320x480
else if(width == 480 && height == 320)
{
BackGroundImage.setBackgroundResource(R.drawable.help);
}
//portrait mode of 480x800
else if(width == 480 && height == 800)
{
BackGroundImage.setBackgroundResource(R.drawable.help);
}
//Landscape mode of 480x800
else if(width == 800 && height == 480)
{
BackGroundImage.setBackgroundResource(R.drawable.help1);
}
//portrait mode of 480x854
else if(width == 480 && height == 854)
{
BackGroundImage.setBackgroundResource(R.drawable.help);
}
//Landscape mode of 480x854
else if(width == 854 && height == 480)
{
BackGroundImage.setBackgroundResource(R.drawable.help1);
}
// help = new ImageView(this);
// help = (ImageView)findViewById(R.id.helps);
}
}
Как я могу решить эту проблему?