我想,以显示我的滚动视图像2 ImageView的这个,但它不工作。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/background_dark"
android:layout_width="fill_parent"
android:fillViewport="true"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
<ImageView
android:id="@+id/imageB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/image"
android:gravity="center" />
</LinearLayout>
</ScrollView>
如果我不使用android:fillViewport =“ true”,我会看到2张图片,但它们的大小已调整。如果我使用的话,尺寸是正确的,但是我无法查看第二张图片。为什么 ?
谢谢
您可以通过编程获取Screen的宽度和高度,然后分别设置ImageView的宽度和高度。这是代码:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
try {
display.getRealSize(size);
int width = size.x;
int height = size.y;
} catch (NoSuchMethodError e) {//to deal with API 8
int height = display.getHeight();
int width = display.getWidth();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句