gpt4 book ai didi

android - 硬件加速破坏了应用程序

转载 作者:搜寻专家 更新时间:2023-11-01 09:08:59 25 4
gpt4 key购买 nike

情况是这样的。

我想为安卓做一个简单的游戏。这对我自己来说是一种教育,所以我想尝试很多可用的功能。

这就是问题所在。

启用硬件加速(通过应用程序或通过在 android 4 中的开发人员选项中强制启用它,会使应用程序的第一个 View 绘制错误。它是一个非常简单的菜单,由帖子底部的 xml 制作。

<更新>

它在 samsung galaxy nexus 上出了问题。第一张图片来自模拟器(终于开始了......)它似乎可以工作。

应该是______________________________________________________________________________________________________________

want is

第二张图片渐变在屏幕上(没有编程)它不是反射或任何东西。您所看到的正是屏幕显示的内容。

白天的时候会拍出更好的照片...

/更新>

我已经恢复到应用程序的最基本/空代码,这意味着唯一的代码是在主 java 类中设置要显示的 View 并且问题仍然存在。

我看到的好像主视图的大小正在调整为我屏幕的 1/4。并且所有 View (按钮可绘制 TextView )都绘制得非常小。

  • 我知道如何禁用硬件加速。
  • 我知道如何为每个 View /Activity 启用和禁用等等。
  • 我知道如何“修复”该应用。

不过我想要的是知道为什么。硬件加速不能在简单的 TextView 或线性布局中实现的是什么?这里到底发生了什么?

抱歉,我的问题有点透彻。我只是找不到有关此的任何信息。对“硬件加速破坏我的应用程序”的通常回答似乎是“将其关闭”。但这算不上“修复”

另请注意,我没有使用文档中描述为与硬件加速不兼容的任何内容。

主要.java:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.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>

list .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>

最佳答案

将targetSdk 和minimumSdk 放在manifest 上,解决显示小 View 的问题。这发生在我身上,但显示屏幕扩大而不是一小部分,可能是因为硬件加速。

关于android - 硬件加速破坏了应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9770191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com