Android 应用文本重影

Android App Text Ghosting

源代码:https(冒号斜杠斜杠)github(圆点)com/rileyclauss/PHSMobile

Android 构建时屏幕上出现 Studio 文本重影。

在构建我的应用程序时,[参见编辑 3] 当我滚动时,文本将保持完全半透明,因此无法阅读文本。 [某些方面也将是视觉乱码、图像 "tile-ing," 静态等] 无论代码的内容如何(即使它是空的。)

每次 activity 都会发生这种情况。

这个例子说明了问题: normal text as opposed to what it looks like now, torn text

有什么解决办法吗?唯一执行的代码是像这样设置布局,所以这不是内存问题。任何帮助都将不胜感激。

EDIT1:这是我正在使用的Java代码

package com.phsapp.phsapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class aboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) { //Yeah, this is it
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    }
}

XML 在这里:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_about"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.phsapp.phsapp.aboutActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView56">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1">

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/introtext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView57" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/introtext2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView58" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/introstats"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView59" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/introtext3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView60" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/points_of_pride"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView61"
            android:textStyle="normal|bold"
            android:textSize="16sp" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/POP1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView62" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/POP2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView63" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/POP3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView64" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/POP4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView65" />

        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>

        <TextView
            android:text="@string/POP5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView66" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/POP6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView67" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/quick_facts"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView68"
            android:textStyle="normal|bold"
            android:textSize="16sp" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/enrollmentfact"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView69" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/tasfact"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView70" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/schedule"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView71" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/schoolcolors"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView72" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/mascot"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView73" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/constructed_1958"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView74" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/extensively_renovated_1996"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView75" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/buildingsize"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView76" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/class_structure"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView77" />
        <Space
            android:layout_width="1dp"
            android:layout_height="5dp"/>
        <TextView
            android:text="@string/schoolschedule"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/textView78" />
        <Space
            android:layout_width="1dp"
            android:layout_height="20dp"/>

        <Button
            android:text="Credits"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/button3"
            android:layout_weight="0.05" />
    </LinearLayout>
</ScrollView>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/abouthead"
    android:id="@+id/imageView3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:cropToPadding="true"
    android:adjustViewBounds="true"
    android:contentDescription="@string/abouttext" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/textView56"
    android:text="@string/comittedexcelence"
    android:textSize="18sp"
    android:textStyle="normal|bold"
    android:textAlignment="center"
    android:layout_below="@+id/imageView3"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

提取每个字符串资源。

Android Studio 2.3

构建 #AI-162.3764568,构建于 2017 年 2 月 24 日

JRE: 1.8.0_112-release-b06amd64

JVM:JetBrains 的 OpenJDK 64 位服务器 VM s.r.o

在拿到这段代码的过程中,我发现它也在撕裂AndroidStudio本身。这可能是我电脑的问题吗?

OS:Windows 10,构建 14393

CPU:英特尔至强 4 核 2.67GHz

内存:16GB

编辑 3: 经过更多测试后,我能够确定这只发生在不使用 GPU 渲染屏幕的设备上。例如,使用 Nexus 5X (Android 7.1.2),如果不强制使用 GPU,GPU 将不会被使用,CPU 会尝试渲染所有内容,失败并导致什么是见上文。在 Samsung Galaxy S7 (Android 7.0) 上测试自然会使用 GPU,一切看起来都应该如此。在 Moto E 2nd Gen (Android 7.1.2) 上,需要启用强制 GPU 渲染才能正常工作。 我已将 (android:hardwareAccelerated="true") 放入我的 Android 清单但无济于事,问题仍然存在。 IDE 本身也会出现此问题。在 XML 文件的 "Design" 模式下,滚动会导致同样的问题。文本将绘制但不会擦除。这在低层和中层计算机上都会发生。 任何解决方案或解决方法都非常受欢迎。

解决方案: 如果您访问提供的 GitHub link,并访问任何旧版本,您可以看到我已经实现了一个具有 "NoActionBar" 父级的自定义主题。当我将主题更改为具有操作栏时,问题在所有设备上都停止了,包括 IDE 本身。