質問

In my application I set android:hardwareAccelerated="true". I have one layout that have large image (1600 x 2500). When I run my application the background was gone all I have black background. So when I set

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

the background image shows again. When I set background as a color it works fine.

So what is the problem here or what I did wrong. I want show image when android:hardwareAccelerated is turned on.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/firstbg"
    android:clickable="true">
</LinearLayout>
役に立ちましたか?

解決

Using android:hardwareAccelerated makes Android to upload your images to CPU memory. There is a limitation there on the size of the image and it also depends on the openGL version. I don't remember what are the max dimensions but your image is probably to large. It works with colors as a different algorithm used to render colors.

I am sure if you will try using a smaller image it will work for you.

Edit: If you must use large image, your only option is cutting it to smaller peaces and use it as some sort of puzzle, but it will effect your performance. Try to find a way to reduce it's size.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top