youri
youri

Reputation: 464

hardware acceleration breaks the app

So here's the situation.

I want to make a simple game for android. It's meant to be educational for myself so i want to try out a lot of available features.

And here's the problem.

Enabling hardware accelartion (trough application or through forcing it in the developers option in android 4, makes the apps first view draw wrong. its a very simple menu made by the xml in the bottom of the post.

< update >

it is on the samsung galaxy nexus where it goes wrong. the first picture is from the emulator (finnally got it to start...) there it seems to work.

as it should be _________________________how it is

want is

the second picture the gradient is in the screen (didnt program it) its not reflection or anything. what you see is exactly what the screen shows.

ill be making better pictures when its daytime...

< / update >

I've reverted back to the most basic/empty code of an app meaning the only code is in the main java class setting this view to be shown and the problem sticks.

What i see is as if the main view is being resized to 1/4 of my screen. and all the views (buttons drawables textviews) are drawn extremely small.

what i want though, is to know why. what is it that hardware accelaration cant in a simple textview or linearlayout. what is actually happening here?

Sorry for being a bit thorough with my question. I just dont find any info about this. The usual answer to 'hardware accelaration breaks my app' seems to be 'turn it off'. But thats hardly a 'fix'

Please also note that i'm not using anything that has been described in the documentation as not compatible with hardware acceleration.

main.java:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView
    android:id="@+id/ilogo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="test"
    android:background="@drawable/logo"
    />
    <Button 
    android:id="@+id/play"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Play"
    android:textSize="24sp"
    android:background="@drawable/button"
    android:textColor="@drawable/button_color"
    />
    <Button 
    android:id="@+id/highscore"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="highscore"
    android:textSize="24sp"
    android:background="@drawable/button"
    android:textColor="@drawable/button_color"
    />
    <Button 
    android:id="@+id/quit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Quit"
    android:textSize="24sp"
    android:background="@drawable/button"
    android:textColor="@drawable/button_color"
    />
</LinearLayout>

manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="lima.ict"
  android:versionCode="1"
  android:versionName="1.0">
<application 
    android:label="@string/app_name" 
    android:icon="@drawable/ic_launcher" 
    android:hardwareAccelerated="true"
    >
    <activity  android:name="pong"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:configChanges="orientation|keyboardHidden"
              >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</manifest>

Upvotes: 2

Views: 1854

Answers (1)

Marcio Covre
Marcio Covre

Reputation: 4556

Put the targetSdk and minimumSdk on the manifest to fix the problem of showing a small view. That happened with me, but showed the screen expanded instead of a small part, maybe it's because of the hardware acceleration.

Upvotes: 3

Related Questions