xamarin.android 相关问题

Xamarin.Android(以前称为Android的Mono)是在Android平台上运行的Mono的实现,允许您使用本机Android库以及使用.NET BCL(基类库)在C#中编写Android应用程序。

Xamarin 支持 Android 14

Xamarin 应用程序不允许在 Samsung Galaxy S23 中上传照片。 甚至应用程序版本也不可见。 我的应用程序的目标是 android SDK API 版本 33,但 Samsung Galaxy S23...

回答 1 投票 0

使用SVG动画创建Android启动画面

我正在使用 Xamarin.Forms 开发一个应用程序,我正在尝试将启动屏幕插入我的 Android 项目。 我找到了一些创建具有背景颜色和统计信息的启动屏幕的教程......

回答 2 投票 0

根据连接情况在后台上传数据

我在理解如何解决这个问题时遇到了问题,因为我对 xamarin 和 android 都很陌生。 我的问题如下:我需要开发一个Android应用程序,它可以拍照......

回答 1 投票 0

Xamarin Android 无法从旋转后的图像中读取 EXIF 数据来检查图像是否旋转

描述 要通过基于方向旋转读取 EXIF 元数据来检查图像是否旋转,然后创建新的位图并将其设置为 ImageView 控件。 实际图像 EXIF 数据...

回答 3 投票 0

Xamarin.Forms 应用程序中的 ExifInterface 方向始终为 0

我正在开发 Xamarin.Forms 应用程序,我想在其中实现拍照功能。 我已经实现了这个功能及其工作原理。但是刚才我在S上遇到了一个问题...

回答 2 投票 0

Microsoft Android 构建失败 - 无法编译本机程序集文件

我已经在 Visual Studio for mac 2022 中从模板创建了一个 Android 项目(检查了支持的 abi:armebi-v7a) 当我构建项目时,我随机收到一个或多个以下错误: Xamarin.并且...

回答 1 投票 0

Xamarin C# Android Zxing 二维码扫描仪

当我尝试激活相机(等待scanner.Scan())时出现异常: System.NullReferenceException:“未将对象引用设置为对象的实例。” 这是我的按钮: 私有异步无效

回答 1 投票 0

Maui Android 兄弟移动打印 SDK 绑定类

通过新的移动 Android 应用程序跳上毛伊岛开发列车。该应用程序的目的是在 Brother RJ2050 移动打印机上打印一份摘要。 我已经下载了 SDK 并按照说明进行操作...

回答 1 投票 0

Xamarin.Forms 无法存档,因为打包过程失败

我单击了Xamarin.Forms的Android项目的存档按钮。 虽然我从其他社区、github issues 做了很多方法,但都失败了。 我已经拥有的设置: 将链接器设置为 On...

回答 2 投票 0

在Xamarin应用程序中集成阿里巴巴的Idaas SDK集成以验证用户身份的流程是怎样的

我想在我的xamarin应用程序中集成alibabas idaas sdk用于登录过程。 同样的过程是什么。 我没有找到有价值的资源来做同样的事情。

回答 1 投票 0

如何在 Android Kitkat 中调整 AppCompatRadioButton 的 DrawableLeft 大小?

在 Xamarin Android 应用程序中,我有一个 AppCompatRadioButton,其 drawableLeft 属性设置为 @drawable/person_resized: 在 Xamarin Android 应用程序中,我有一个 AppCompatRadioButton,其 drawableLeft 属性设置为 @drawable/person_resized: <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatRadioButton android:id="@+id/MyRadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Selection 1" android:textSize="24dp" android:drawableLeft="@drawable/person_resized" android:drawablePadding="5dp" /> </RadioGroup> drawable/person_resized.xml 是一个图层列表可绘制对象,我用它来缩小 drawable/person.png 图像: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/person" android:width="22dp" android:height="22dp" /> </layer-list> 当此视图显示在 Android N 模拟器上时,它的行为正常。 但是在我的 Android Kitkat(4.4.4) 设备中,图像大小不正确。 这是我在 Android N 中得到的: 这是我在 Android Kitkat 中得到的: 这是怎么回事? 我尝试了以下方法来缩小 Android Kitkat 中的 drawableLeft 的大小,但 都不起作用: 使用ScaleDrawable缩小可绘制对象,同时确保SetLevel,这实际上允许调整可绘制对象的大小,但不受控制;无论我提供什么缩放系数,调整大小的图像始终是相同的较小尺寸 从可绘制对象中获取位图,调整其大小并创建一个新的位图可绘制对象,但这会使图像消失 使用插入可绘制对象,与使用图层列表相同,使图像以其原始大小显示 根据Mahmoud Mortda指出的这个答案,Android Kitkat 中的一些功能障碍导致图层列表调整大小被忽略。 所以基本上你必须自己做,以下是我所做的: 我创建了两个文件 layout-v21/radio_group.xml 和 layout/radio_group.xml,前者将用于运行至少 Lollipop (SDK 21) 的 Android 设备,后者将用于包括 KitKat 在内的其余设备。 layout-v21/radio_group.xml 包含通过 RadioGroup 调整大小的图像的 layer-list: <?xml version="1.0" encoding="utf-8"?> <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatRadioButton android:id="@+id/MyRadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Selection 1" android:textSize="24dp" android:drawableLeft="@drawable/person_resized" android:drawablePadding="5dp" /> </RadioGroup> layout/radio_group.xml 包含一个 RadioGroup,带有由 ImageView 和 TextView 制成的“手工制作”标签: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:id="@+id/RadGroup"> <android.support.v7.widget.AppCompatRadioButton android:id="@+id/MyRadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24dp" /> </RadioGroup> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/RadGroup" android:layout_centerVertical="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/icon" android:layout_width="22dp" android:layout_height="22dp" android:src="@drawable/person" android:layout_alignParentLeft="true" android:layout_centerVertical="true" /> <TextView android:id="@+id/label1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_toRightOf="@+id/icon" android:layout_centerVertical="true" android:textSize="24dp" android:textColor="@color/black" android:text="Selection 1" /> </RelativeLayout> </RelativeLayout> 这里使用 ImageView 让我可以有效地调整图像大小。 最后,在包含 RadioGroup 的 xml 布局中,只需包含 @layout/radio_group,SDK 将加载针对 Android 版本的正确布局: <include layout="@layout/radio_group"/> 添加RadioButton。 <androidx.appcompat.widget.AppCompatRadioButton android:id="@+id/dialog_pedido_item_produto_desconto_radio_button_desconto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:buttonTint="@color/red_600" android:bufferType="spannable" android:gravity="center" android:drawableStart="@drawable/ic_arrow_downward_red_24dp" android:checked="true" android:padding="@dimen/dp_5" android:text="Desconto" />

回答 2 投票 0

Xamarin Android,java类ListenableFuture被定义多次,带有新的Andriod App

我在 Visual Studio 2022 中创建了一个全新的 Xamarin Android 应用程序。 然后,我引用了 Xamarin.Stripe.Terminal.Android 库的 v1.0.17.2,因为我需要在...上执行一些事务

回答 1 投票 0

.NET MAUI 无法绑定到目标方法,因为其签名与委托类型的签名不兼容

当我启动应用程序时,它崩溃并出现异常:无法绑定到目标方法,因为它的签名与委托类型的签名不兼容。初始屏幕上出现错误。这...

回答 1 投票 0

循环遍历在android视图中动态创建的子视图

我有一个视图,在其中动态添加了多个 EditText 视图,并且我需要循环访问这些视图以捕获输入的任何数据。我在 StackOverflow 上查看了这个解决方案: 公共空间

回答 1 投票 0

Xamarin 表单 OnBackButtonPressed 自升级以来未在 Android 上触发

我有一个使用 AndroidX Xamarin 之前版本、Java V8 (C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot) 在 Android 8.1 设备上运行的应用程序 我现在需要它在 Android 版本 8 的设备上运行...

回答 1 投票 0

Java.Lang.IllegalArgumentException .NET MAUI

安装 BarcodeScanner.Mobile 版本 8.0.0.1 后,应用程序启动时出现此异常:MAUI Java.Lang.IllegalArgumentException: '此组件要求您指定有效的

回答 1 投票 0

.NET MAUI 在两个 TabBar 之间切换时重绘动画

我在 AppShell.xaml 中有两个 TabBar,可以在它们之间切换。 我在 AppShell.xaml 中有两个 TabBar,可以在它们之间切换。 <TabBar> <Tab Title="Novinky"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconHome}"></FontImageSource> </Tab.Icon> <ShellContent Title="Home" ContentTemplate="{DataTemplate view:HomePage}" Route="HomePage" /> </Tab> <Tab Title="Skupiny"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconGroups}"></FontImageSource> </Tab.Icon> <ShellContent Title="Skupiny" ContentTemplate="{DataTemplate view:GroupListPage}" Route="GroupListPage" /> </Tab> <Tab Title="Profil"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconUser}"></FontImageSource> </Tab.Icon> <ShellContent Title="Profil" ContentTemplate="{DataTemplate view:ProfilePage}" /> </Tab> </TabBar> <TabBar> <Tab Title="Oznámení"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconAnnouncement}"></FontImageSource> </Tab.Icon> <ShellContent Title="Oznámení" ContentTemplate="{DataTemplate view:GroupPage}" Route="GroupPage" /> </Tab> <Tab Title="Testy"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconTrials}"></FontImageSource> </Tab.Icon> <ShellContent Title="Testy" ContentTemplate="{DataTemplate view:GroupTrialsPage}" Route="GroupTrialsPage" /> </Tab> <Tab Title="Detail"> <Tab.Icon> <FontImageSource FontFamily="FASolid" Glyph="{StaticResource IconInfo}"></FontImageSource> </Tab.Icon> <ShellContent Title="Detail" ContentTemplate="{DataTemplate view:GroupDetailPage}" Route="GroupDetailPage" /> </Tab> </TabBar> 我像这样从 GroupListPage 导航到 GroupPage await Shell.Current.GoToAsync($"///{nameof(GroupPage)}", true, new Dictionary<string, object>() { { "Group", group } }); 导航本身工作正常,但看起来 TabBar 正在开关上重新绘制并具有这种动画,它看起来很糟糕,特别是在黑暗模式下。此外,它的行为仅在 Android 上如此。 Windows 上没有这样的行为。我不知道iOS。 我尝试更改 Styles.xaml 中 Shell 属性的颜色,但没有成功。知道如何摆脱它或者只是改变它的颜色吗? 导航本身工作正常,但看起来 TabBar 正在开关上重新绘制并具有这种动画,它看起来很糟糕,特别是在黑暗模式下。此外,它的行为仅在 Android 上如此。 Windows 上没有这样的行为。我不知道iOS。 我测试了您提供的代码并重现了问题。我们尝试使用 Binding 和 INotifyPropertyChanged 来动态改变 TabBar 的 Visible 但以失败告终。它仍然有那种动画。您可以在MAUI问题GitHub上报告它。让我们的开发人员知道并处理它。 但是,如果您愿意尝试使用TabbedPage,它可以消除这种动画。您可以看到以下代码: App.xaml.cs: public partial class App : Application { public static MyTabbedPage1 MyTabbedPage1; public static MyTabbedPage2 MyTabbedPage2; public App() { InitializeComponent(); MainPage = MyTabbedPage1 = new MyTabbedPage1(); MyTabbedPage2 = new MyTabbedPage2(); } } 我的选项卡页面1: <TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls" android:TabbedPage.ToolbarPlacement="Bottom" xmlns:view="clr-namespace:MauiApp2.Views" x:Class="MauiApp1.MyTabbedPage1" Title="MyTabbedPage1"> <view:HomePage Title="Novinky" /> <view:GroupListPage Title="Skupiny"/> <view:ProfilePage Title="Profil"/> </TabbedPage> 我的选项卡页面2: <TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls" android:TabbedPage.ToolbarPlacement="Bottom" xmlns:view="clr-namespace:MauiApp2.Views" x:Class="MauiApp2.MyTabbedPage2" Title="MyTabbedPage2"> <view:GroupPage Title="Oznámení" /> <view:GroupTrialsPage Title="Testy"/> <view:GroupDetailPage Title="Detail"/> </TabbedPage> 群组列表页面: public partial class GroupListPage : ContentPage { public GroupListPage() { InitializeComponent(); } private async void Button_Clicked(object sender, EventArgs e) { App.Current.MainPage = App.MyTabbedPage2; await Navigation.PushAsync(new GroupPage()); } } 群组页面: public partial class GroupPage : ContentPage { public GroupPage() { InitializeComponent(); } private async void Button_Clicked(object sender, EventArgs e) { App.Current.MainPage = App.MyTabbedPage1; await Navigation.PushAsync(new GroupListPage()); } } 这是。

回答 1 投票 0

如何从证书获取/生成pin sha256

简单的问题 我正在尝试使用网络安全配置在 android 中进行证书固定 但我不知道如何将 SHA-256 放入引脚组中 给定一个域名 url,你如何...

回答 2 投票 0

如何将 ZXing.Net.Maui 集成到部分转换的 Xamarin.Android 到 .NET MAUI 项目中以进行 QR/条形码扫描?

我正在将 Xamarin.Android 项目转换为 .NET MAUI。该项目是 WebView 的轻量级包装,UI 主要由用以下语言编写的单独项目处理:

回答 1 投票 0

Android 将设置图标齿轮添加到应用程序信息

我正在使用 Xamarin Forms 并尝试将“设置”图标齿轮添加到我的应用程序信息中,这就是我尝试过的: 将其添加到应用程序节点内的 AndroidManifest.xml 中: 我正在使用 Xamarin Forms 并尝试将“设置”图标齿轮添加到我的应用程序信息中,这是我尝试过的: 将此添加到应用程序节点内的AndroidManifest.xml: <activity android:name=".ui.SettingsActivity" android:label="Settings" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" /> </intent-filter> </activity> 在我的根目录中创建了一个名为 SettingsActivity.cs 的文件并添加了此代码,我收到错误: “当前上下文中不存在名称“AddPreferencesFromResource””): using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using Android.Preferences; namespace RegistrationApp.Droid { [Activity (Label = "SettingsActivity")] [Obsolete] public class SettingsActivity : Activity { protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Create your application here AddPreferencesFromResource(Resource.Xml.preferences); } } } 我在资源中创建了一个 xml 文件夹,并在新的 xml 文件夹中创建了一个名为 preferences.xml 的文件,并添加了以下代码: <?xml version="1.0" encoding="UTF-8" ?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="General"> <EditTextPreference android:key="edit_text_preference" android:title="EditText Preference" android:summary="This is an EditText preference" android:dialogTitle="Enter your text" /> <!-- Add more preferences as needed --> </PreferenceCategory> </PreferenceScreen> 我收到错误“当前上下文中不存在名称“AddPreferencesFromResource””,因此更改了此内容: public class SettingsActivity : Activity到此public class SettingsActivity : PreferenceActivity并且解决了错误,但应用程序信息中仍然没有设置齿轮...我做错了什么吗? 我的目标是在应用程序信息中设置设置,以便用户能够更改。 按照“在 PreferenceActivity 中使用什么来代替“addPreferencesFromResource”?”,您可能需要 AndroidX 库中的 PreferenceFragmentCompat,而不是已弃用的 PreferenceActivity#addPreferencesFromResource 方法。 <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.4" /> 您的 SettingsActivity 应扩展 AppCompatActivity 并主持 PreferenceFragmentCompat。 [Activity(Label = "Settings")] public class SettingsActivity : AppCompatActivity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SupportFragmentManager .BeginTransaction() .Replace(Android.Resource.Id.Content, new SettingsFragment()) .Commit(); } } 实现 SettingsFragment 扩展 PreferenceFragmentCompat 并从资源文件加载首选项: public class SettingsFragment : PreferenceFragmentCompat { public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey) { SetPreferencesFromResource(Resource.Xml.preferences, rootKey); } } 您的 preferences.xml 文件保持不变。 确保您的 AndroidManifest.xml 反映了正确的活动名称。如果您的 SettingsActivity 位于特定命名空间内,请确保正确指定: <activity android:name=".SettingsActivity" android:label="Settings" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" /> </intent-filter> </activity>

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.