0
我'使用全屏和锁定肖像。在清单:Imageview的位置不像预期的那样
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait"
在布局我有一个ImageView的和两个按钮:
<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/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
一开始我打开我自己的形象进入的ImageView:
imageView = (ImageView) findViewById(R.id.imageView1); //from .xml
Drawable newPhoneImage;
newPhoneImage = getResources().getDrawable(R.drawable.phone_on);
imageView.setImageDrawable(newPhoneImage);
在两个我的模拟器按预期在屏幕顶部显示图像。
我然后制定一个位图和替换图像:
sBitmap = Bitmap.createBitmap(557, 580,Config.ARGB_8888);
//draw the bimap image
BitmapDrawable nimage;
nimage = new BitmapDrawable(sBitmap);
imageView.setImageDrawable(nimage);
在大仿真器(WVGA800 400x800)的图像是在顶部按预期方式。
在小型仿真器(QVGA 240x320)和我的手机(240x320)上,图像从顶部向下35像素。
他们为什么不同?
我可以滚动图像起来:
imageView.scrollTo(0, 35); //this will put image at top
我如何才能找到这个价值?没有像这样的工作:
int offset = imageView.getTop();// it just = height of image
任何帮助,将不胜感激。