How can I painlessly change my app Title text color?

你离开我真会死。 提交于 2020-05-18 21:04:33

问题


Android Studio UIApplication UI

See attached Android Studio UI image: I want to change the Title Text COLOR from white to gray; every XML variation I have tried has not worked; where in the attached activity_scrolling.xml file can I change the Title text to gray - and it work?

How do I painlessly change the text color from white to gray for my application Title? I am using Android Studio 2.3.3 and have poured through the XML files for style, color, and my activity XML files making attempts at changing the Title text color from white to gray and have not been successful doing such a simple task - it is not intuitive how to do this. Please help, thanks.


回答1:


This should work. Go to your styles.xmls file.

<style name="TextAppearance.AppCompat.Widget.ActionBar.Title" parent="@style/TextAppearance.AppCompat">

    <item name="android:textSize">TEXT_SIZE_HERE</item>
    <item name="android:textColor">COLOR_RESOURCE_HERE</item>
    <item name="android:fontFamily">FONT_HERE</item>
</style>

Edit accordingly. Video tutorial here [https://www.youtube.com/watch?v=510WE8CmiXI][1]




回答2:


I found the solution for you.

Go to styles.xml in res->values and in your theme add one item like this:

<item name="titleTextColor">@color/yourColorTitle</item>

Now you just have to add the desired color in the colors.xml resource file in res->values->colors.xml like this:

<color name="yourColorTitle">#000000</color>



回答3:


In your XML file, for the TextView element, add the android:textColor attribute, with the choice of your color as its value.

<TextView
 android:id..
 android:layout_width..
 android:layout_height..
 android:text=..
 android:textColor="#D3D3D3"
/>



回答4:


For this, you need to find the AnroidManifest.xml file.

Using your IDE navigate to app -> src -> main -> AnroidManifest.xml

Option 1: If you're in android studio go inside AndroidManifest.xml and double click on android:label="@string/app_name" and it will take you to where you can change the value to whatever you want

Option2: Directly go to app -> src -> main -> res -> values -> strings.xml and change the name to whatever you want.

NOTE: Please note that it is not recommended to hard code the value of the app name like android:label="HARDCODED name" as this will break the app in case you want to include features like a translation.




回答5:


Go into styles.xml and inside style AppTheme add

<item name="android:textColorPrimary">#b5b5b5</item>

where #b5b5b5 is grey color. You can insert any color you want.

Complete code looks like this (if someone can't find AppTheme):

<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>
    <item name="android:textColorPrimary">#b5b5b5</item>
</style>


来源:https://stackoverflow.com/questions/45527871/how-can-i-painlessly-change-my-app-title-text-color

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!