我的 xaml 在模拟器中正确显示时遇到问题,但在打包并安装到 Android 手机上时却出现问题。另外,堆栈布局中的普通标签根本不会显示在我的手机上,它们可能是白色的! 关于我手机上的应用程序性能,它的功能与模拟器中的一样,按钮也与模拟器中的位置相同,但不可见。 我正在使用 Pixel 5 进行测试,并在模拟器上测试了 OnePlus 5,我的手机是 OnePlus 5T。
正如您在图片中看到的那样,文本显示正确,但详细信息未显示? 我是编程新手,不知道这是否是我的风格未定义的问题......或者哪些颜色会改变文本甚至背景。
代码:
设置页面
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bottom_Tab.Views.SettingsPage"
Title="Settings">
<ContentPage.Content>
<TableView Intent="Settings">
<TableRoot>
<TableSection Title="Settings">
<TextCell Text="Language" Detail="" TextColor="Black" />
</TableSection>
<TableSection Title="User">
<TextCell Text="Login" TextColor="Black" Tapped="Login_Tapped"/>
<TextCell Text="Logout" TextColor="Black" Tapped="Logout_Tapped"/>
<TextCell Text="UserName" Detail="Change Username" TextColor="Black" />
</TableSection>
<TableSection Title="Other">
<TextCell Text="Version" Detail="a23w49b" TextColor="Black" />
<TextCell Text="Credits" TextColor="Black" Tapped="Credits_Tapped" />
</TableSection>
</TableRoot>
</TableView>
</ContentPage.Content>
</ContentPage>
“Project.Android”中的Sytles.xaml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<!-- As of Xamarin.Forms 4.6 the theme has moved into the Forms binary -->
<!-- If you want to override anything you can do that here. -->
<!-- Underneath are a couple of entries to get you started. -->
<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<!--<item name="colorPrimary">#2196F3</item>-->..
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#00FF96</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#ff006a</item>
</style>
</resources>
“Project.Android”中的colors.xaml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="launcher_background">#FFFFFF</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
此外,我没有更改 apk 名称,SDK 版本是 android 5-13,我的手机是 android 9。所以这应该不是问题。
我尝试将colors.xaml中的启动器背景从白色更改为灰色,看看我手机上的文字是否真的只是白色! 并在互联网上寻找答案,但没有找到任何东西。
<color name="launcher_background">#888888</color>
但是背景颜色没有改变。