Ich habe ein Problem festgestellt, das mich dazu gebracht hat, mir ein paar Tage die Haare auszuziehen, und Googeln und Suchen hier hat niemanden aufgedeckt, der das selbe angetroffen zu haben scheint. Ich habe Java an der Universität gelernt, aber ich lerne gerade erst Android. Ich arbeite gerade an einer Schule und habe in meiner Freizeit eine grundlegende Lernquiz-App aufgebaut, um mit Kindern im Unterricht zu spielen, aber ich habe ein Layout-Verhalten kennengelernt, das ich einfach nicht verstehe.Anzeigen von Text im Android-Layout, das zuvor standardmäßig schwarz war, ist jetzt standardmäßig grau. Ich kann nicht herausfinden, was sich geändert hat.
Als ich diese App startete, war der Text immer schwarz oder zumindest so dunkelgrau, dass ich den Unterschied nicht wirklich erkennen konnte. Jede Aktivität, die ich auslegte, hatte einen schönen, dunklen Text. Ich habe eine davon modifiziert, um vor ein paar Tagen TextView-Beschriftungen über einigen Fortschrittsbalken hinzuzufügen, und bemerkte, dass der Text auf den Etiketten etwas blasser als gewöhnlich erschien, aber als AA ablehnte, da die Schrift so klein war und alle zuvor hinzugefügte Komponenten waren immer noch schön und dunkel. Als ich jedoch danach eine andere, neue Aktivität erstellte, war die Textfarbe jedes TextView, das ich hinzufügte, das gleiche mittlere Grau von den vorherigen Labels. Ich kann die Farbe dieser Etiketten individuell einstellen, was auch immer ich mag, und sie ändern sich, aber ich sehe nicht, warum ich dies für jede neue Ansicht in jeder neuen Aktivität tun sollte, während die bereits existierenden wie immer funktionieren. Ich verstehe nicht, warum sie sich anders verhalten.
Ich habe versucht, "@ Farbe/schwarz" im App-Thema "AppTheme", die ich zuvor nie berührt hatte, und während der Text wurde schwarz, brach es deaktivieren Tasten, in dem sie schwarz bleiben würde statt Farbe ändern, wenn deaktiviert, so sah immer noch aktiv aus. Außerdem würde ich lieber verstehen, was schiefgelaufen ist, als dass es klamm ist.
Kann mir also jemand sagen, warum der TextView-Text im ersten der folgenden Layouts standardmäßig eine Art von mittlerem Grau hat, während der Text im zweiten standardmäßig schwarz ist? Ich kann nicht sehen, was der Unterschied ist, und sie haben sogar die gleiche verschachtelte Layoutstruktur haben, aber sie machen in verschiedenen Farben ...
Neue Aktivitäten Layout macht weirdly grau:
<?xml version="1.0" encoding="utf-8"?>
<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"
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=".QuestionResultsPageActivity">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/questionTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/questionTitleTextViewTopMargin"
android:text="@string/questionTitleTextViewText"
android:textSize="@dimen/questionTitleTextViewTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/questionTextTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/questionTitleTextView"
android:layout_marginLeft="@dimen/controls_horizontal_margin"
android:layout_marginRight="@dimen/controls_horizontal_margin"
android:text="@string/questionTextTextViewText"
android:textSize="@dimen/questionTextTextViewTextSize" />
<TextView
android:id="@+id/answerTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/questionTextTextView"
android:layout_marginTop="@dimen/answerTitleTextViewTopMargin"
android:text="@string/answerTitleTextViewText"
android:textSize="@dimen/answerTitleTextViewTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/answerLetterTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/answerTitleTextView"
android:layout_marginLeft="@dimen/controls_horizontal_margin"
android:layout_marginRight="@dimen/answerLabelSpacing"
android:text="@string/answerLetterTextViewText"
android:textSize="@dimen/answerLabelTextViewTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/answerTextTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/answerTitleTextView"
android:layout_toRightOf="@id/answerLetterTextView"
android:text="@string/answerTextTextViewText"
android:textSize="@dimen/answerTextTextViewTextSize" />
<TextView
android:id="@+id/resultsTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/answerTextTextView"
android:layout_marginTop="@dimen/resultsTitleTextViewTopMargin"
android:text="@string/resultsTitleTextViewText"
android:textSize="@dimen/resultsTitleTextViewTextSize"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/resultsBlockLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/resultsTitleTextView"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/questionResultTeamNamesLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/questionResultTeamNameHeadingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team"
android:textSize="@dimen/teamResultsNameTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/questionResultTeamNameTextView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 1"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 2"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 3"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 4"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 5"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 6"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 7"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 8"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team 9"
android:textSize="@dimen/teamResultsNameTextSize" />
</LinearLayout>
<LinearLayout
android:id="@+id/questionResultTeamAnswerLetterLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/questionResultTeamNameTextView_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\?"
android:textSize="@dimen/teamResultsNameTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/questionResultTeamNameTextView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
<TextView
android:id="@+id/questionResultTeamNameTextView_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="@dimen/teamResultsNameTextSize" />
</LinearLayout>
<LinearLayout
android:id="@+id/questionResultTeamTimesLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/questionResultTeamTimeHeadingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time"
android:textSize="@dimen/teamResultsTimeTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
<TextView
android:id="@+id/questionResultTeamTimeTextView_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123 + 27 = 150"
android:textSize="@dimen/teamResultsTimeTextSize" />
</LinearLayout>
<LinearLayout
android:id="@+id/questionResultTeamScoresLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/questionResultTeamScoreHeadingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Score"
android:textSize="@dimen/teamResultsScoreTextSize"
android:textStyle="bold" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
<TextView
android:id="@+id/questionResultTeamScoreTextView_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 + 1 = 11"
android:textSize="@dimen/teamResultsScoreTextSize" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
<Button
android:id="@+id/questionResultOKButton"
android:layout_width="@dimen/okButtonWidth"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:onClick="askNextQuestion"
android:text="@string/okButtonLabelText"
android:textSize="@dimen/okButtonLabelTextSize" />
</RelativeLayout>
Kurioserweise ist der Text auf der Schaltfläche unten in diesem Layout immer noch dunkel/schwarz. Alle TextViews sind zwar in der Mitte grau (obwohl die in älteren Aktivitäten nicht sind).
Whoops, kein Platz in der Post für das nächste Layout wegen 30K Zeichen Grenze. Wird separat als neue Antwort hinzugefügt. Vielleicht kann jemand sehen, was anders ist.
Oh, und nur für den Fall, AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="//REDACTED">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
//ALL DARK, NO PROBS
<activity
android:name=".StartPageActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//ALL DARK, NO PROBS
<activity
android:name=".AskQuestionActivity"
android:screenOrientation="portrait">
</activity>
//ALL DARK, NO PROBS
<activity
android:name=".TeamEntryActivity"
android:screenOrientation="portrait">
</activity>
//ALL DARK, NO PROBS
<activity
android:name=".AnswerEntryActivity"
android:screenOrientation="portrait">
</activity>
//SOME GREY IN RECENT EDITS (in the ProgressBar label TextViews)
<activity android:name=".GameResultsPageActivity">
android:screenOrientation="portrait">
</activity>
//ALL GREY, WTF?!
<activity android:name=".QuestionResultsPageActivity">
android:screenOrientation="portrait">
</activity>
</application>
</manifest>
und styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
ich dies erst nach dem nicht berührt hatte, Problem trat auf, als ich versuchte, Dinge zu reparieren. Ist das übergeordnete Thema "Theme.AppCompat.Light.DarkActionBar" das übliche Standardparent? Ich weiß nicht, wie ich es hätte ändern können, aber könnte es die Quelle der blassen Standardtextfarbe sein?
Wie kann ich die Standardeinstellungen der Standardthemen finden? (Wie "PrimaryTextColor" von "Theme.AppCompat.Light.DarkActionBar"?)
Ich würde gerne verstehen, was hier passiert ist, wenn möglich, damit ich es in Zukunft vermeiden kann.
Hat meine Antwort Ihnen geholfen? –