图像以三星gs2和较小屏幕尺寸显示,但不在10.1英寸平板电脑中显示

时间:2012-11-04 10:51:46

标签: android android-layout android-intent

我似乎有一个我似乎无法弄清楚的问题。在我的应用程序中,我有一个图像800x2200(在Photoshop中创建)。当我在我的三星gs2上测试应用程序时,图像显示完美,可以上下滚动而没有任何问题。当在较小的屏幕尺寸上进行测试时效果很好,但似乎当我在10.1英寸的屏幕上测试时,我只是得到一个空白的屏幕,但仍然可以滚动(因为我可以看到左边的滚动条,(好像有一个图像,但它没有显示)我已将图像放在所有可绘制的文件夹中,但没有运气。有没有人知道问题是什么或是我做错了什么? 感谢

抱歉,代码是:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    setContentView(R.layout.sample);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    final SlidingDrawer slider = (SlidingDrawer) findViewById(R.id.slidingD1);
    Display d = getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    d.getMetrics(dm);
    Log.d("DISPLAYINFO", "Classified density: " + dm.densityDpi + ", scaled density: " + dm.scaledDensity + ", actual densities: x: " + dm.xdpi + ", y: " + dm.ydpi);
    slider.animateOpen();

    Button next = (Button) findViewById(R.id.img1);
    .....

    next.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
        ((ImageView) findViewById(R.id.imageV1)).setImageResource(0);
        ((ImageView) findViewById(R.id.imageV1)).setImageResource(R.drawable.image1);
        slider.animateClose();
        } 
    });
    ......
}
}

和xml文件:

<RelativeLayout 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">

<ScrollView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
   <RelativeLayout 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content">    

<ImageView 
    android:id="@+id/imageV1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitStart"/>

</RelativeLayout>
 </ScrollView>

<SlidingDrawer
    android:id="@+id/slidingD1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:content="@+id/content"
    android:handle="@+id/handle">

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Select Sample"/>

    <RelativeLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background_image">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true" >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <Button
                    android:id="@+id/samp1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="@drawable/samplethumb1"
                    android:text="Sample1"
                    android:textColor="#FFFFFF"
                    android:textSize="20dp"
                    android:textStyle="bold"
                    android:typeface="serif" />

1 个答案:

答案 0 :(得分:1)

检查LogCat,是否表示错误,如

  

OpenGLRenderer:位图太大而无法上传到纹理

的任何位置?更改是,您的10.1平板电脑与您的小型设备明显不同,因为它在冰淇淋三明治上运行。这意味着默认情况下硬件加速 on ,这可能会使图像尺寸在两个维度上最大化为2048像素。

如果这似乎是问题,请尝试turning off hardware acceleration for your activity。不幸的是,目前不支持将其关闭为单个视图。

相关问题