当前位置: 首页 > 知识库问答 >
问题:

Xamarin Android与appcompat使我所有的文本白色

孙震博
2023-03-14

我正在尝试理解和实现我的Xamarin Android应用程序的材料主题。我已经阅读了像这篇博文和Android留档这样的资源。但我想我仍然错过了一些重要的东西。

简而言之:我已将父主题设置为“主题”。AppCompat。光DarkActionBar’。并且所有文本(textview)都是白色的。我想尽可能遵守材料设计指南。

价值/styles.xml

  <style name="MyTheme" parent="MyTheme.Base">
  </style>

  <style name="MyTheme.Base" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="android:windowActionBar">false</item>
  </style>

价值-v21

  <style name="MyTheme" parent="MyTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
  </style>

AndroidManifest。xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="MaterialDesignTest1.MaterialDesignTest1" android:versionCode="1" android:versionName="1.0">
    <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="21" />
    <application android:label="MaterialDesignTest1"  android:theme="@style/MyTheme"></application>
</manifest>

Mainactivity.cs

[Activity(Label = "MaterialDesignTest1", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : FragmentActivity
{
    /* Omitted the viewpager & tablayout code */
}

还有电影碎片。正在加载到选项卡中的axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:text="Fragment that shows all Starwars Films information 1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="30dp" />
</LinearLayout>

当我将父级更改为父级="@style/Theme. AppCompat. Light"父级="主题。AppCompat. Light"

将SDK目标设置为23会有一些变化,但仍然是白色字体:

什么属性赋予所有字体白色?为什么呢?

Xamarin:4.0.0.1717

Xamarin Android:6.0.0.35

所有Xamarin支持包:23.1.1.0

共有1个答案

郭云
2023-03-14

如果要为应用程序设置特定颜色,请确保在MyTheme中。添加的基数

   <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">@color/accent</item>

您可能还应该使用AppCompatActivity而不是FragmentaActivity。

 类似资料:
  • < li >我创建了一个扩展名无效的文件(。jjs)从我的粘性键盘。 < li >我删除了这个文件 < li >我的所有文件的所有图标都变成文本图标。我丢失了我的颜色主题,没有变量被突出显示,一切都像一个纯文本文件。 我该怎么解决这个问题?我在帮助文档中找不到任何东西 我目前正在运行IntelliJ 2017.3.2

  • 所以,在JavaFX上切齿,到目前为止一切进展顺利。 然而,所有文本字段都有一条横跨它们的线,从顶部算起大约10px。 不仅在我的应用程序中,在SceneBuilder应用程序中也是如此。 注意,我没有使用任何明确的CSS,我不知道SceneBuilder使用什么。屏幕截图来自SceneBuilder,我的屏幕看起来一样。 所以,这是基本的东西。 在Mac OS 10.9.5上 只是好奇是否还有人

  • Android主题有什么不同。AppCompat和Base。主题AppCompat?我们什么时候应该使用基本主题?

  • 我正在开发一个应用程序和一个库(Android模块)。它们在不交互时没有问题:在导入库后,Android Studio搞乱了设置,我无法恢复。 和其他98个类似的:都与主题问题有关。 还有其他消息引用值、,例如:

  • 好的,我的vs代码正常,然后我重新启动了我的笔记本电脑,没有关闭应用程序。我打开后,几乎所有的文字都是白色的。这不是主题,因为它总是在黑暗中。我想我没有点击任何会导致这一点的重要内容。这样编码真的很难。顺便说一下,这是javascript文件。 正如您所看到的,绿色的注释是白色的,文件导入和橙色的文本是白色的“等待”是指紫色是白色。即使“const”也是白色的。有人知道如何解决这个问题吗?

  • 我不是在引用Android5 SDK或兼容库v21,那么为什么它会困扰我这个资源键呢?