小编Oma*_*ada的帖子

将"Android.Views.ViewGroup"添加到Xamarin XAML页面

我需要一些帮助Android.Views.ViewGroup才能添加到XAML页面.

我有一个Xamarin项目,其解决方案结构如下所示:

  • APP1
    • /的ViewModels
      • /MyPageViewModel.cs
    • /浏览次数
      • /MyPageView.xaml
        • /MyPageView.xaml.cs
  • App1.Android
    • /MainActivity.cs
    • /MainApplication.cs
  • App1.iOS
  • MyAndroidBindingProject
    • /罐
      • /customViewGroup.aar

请注意customViewGroup.aar我使用Xamarin Android绑定库添加到解决方案中.

AAR文件包含一个Android.Views.ViewGroup我想要显示的类,MyPage.xaml但我不知道如何做到这一点.我似乎无法找到适合这个确切用例的指南或代码示例(我也找不到涉及向Android.Views.ViewXamarin XAML页面添加简单的一个).

我已经找到了添加Android.Views.ViewGroup到本机Android应用程序(使用Java和XML)的示例,但没有显示如何将其添加到Xamarin XAML页面.

请帮忙!


我包含了一些源代码,以便您可以看到我尝试过的内容:

MyPage.xaml

<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="App1.Views.MyPage"
    xmlns:vm="clr-namespace:App1.ViewModels;"
    xmlns:androidWidget="clr-namespace:Com.CustomAAR;assembly=Com.CustomAAR;targetPlatform=Android"
    xmlns:formsAndroid="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.Platform.Android;targetPlatform=Android"
    Title="{Binding Title}">
    <ContentPage.Content>
        <ContentView x:Name="contentViewParent">
            <androidWidget:MyCustomViewGroup x:Arguments="{x:Static formsandroid:Forms.Context}"> 
            </androidWidget:MyCustomViewGroup>
        </ContentView>
        <!--<ContentView 
            IsVisible="True"
            IsEnabled="True"
            BindingContext="{Binding MyCustomViewGroup}">
        </ContentView>-->
    </ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

MyPage.xaml.cs

public partial class MyPage : ContentPage
{
    MyCustomViewGroupModel viewModel;

    public MyPage()
    {
        InitializeComponent ();
    }

    public MyPage(MyCustomViewGroupModel viewModel) …
Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin.android xamarin xamarin.forms

9
推荐指数
1
解决办法
677
查看次数

多层视差,数学问题

我有一个目前半工作的多层视差脚本.如果让我们说具有视差效果的元素放在网站的顶部,那么效果就会有效,因为当它滚出视图时你无法看到图层移出框架.

但是我希望能够在整个页面的多个元素上,在不同的位置使用此脚本.请参阅下面的示例,您可以看到效果正常,但如果您在该data-parallax="panel-1"部分添加一些边距,您将看到现在存在问题.

/**
 * @author Martyn Lee Ball
 * @desc Creates multi-layer Parallax effect
 * @version 1.0
 * @return {Array} Returns instances of classes as Array
 */
class Parallax {

    constructor(node) {
        const self = this;

        // Settings and defaults
        self.settings = {
            container: node,
            height: node.clientHeight,
            name: node.dataset.parallax,
            layers: [],
            defaultDepth: 0.5,
            offset: function(element) {
                let top = 0;
                do {
                    top += element.offsetTop  || 0;
                    element = element.offsetParent;
                } while(element);

                return {
                    top: self.normalizeInt(top)
                };
            }.call(self, …
Run Code Online (Sandbox Code Playgroud)

javascript parallax

9
推荐指数
1
解决办法
348
查看次数

R中连续神经网络训练中数据的归一化

随着我的输入不断涌现,我想实现对神经网络的持续训练.但是,当我获得新数据时,标准化值将随时间而变化.让我们说,我得到的时间:

df <- "Factor1 Factor2 Factor3 Response
        10      10000   0.4     99
        15      10200   0       88
        11      9200    1       99
        13      10300   0.3     120"
df <- read.table(text=df, header=TRUE)

normalize <- function(x) {
    return ((x - min(x)) / (max(x) - min(x)))
}

dfNorm <- as.data.frame(lapply(df, normalize))

### Keep old normalized values
dfNormOld <- dfNorm 

library(neuralnet)
nn <- neuralnet(Response~Factor1+Factor2+Factor3, data=dfNorm, hidden=c(3,4), 
    linear.output=FALSE, threshold=0.10,  lifesign="full", stepmax=20000)
Run Code Online (Sandbox Code Playgroud)

然后,随着时间的推移,

df2 <- "Factor1 Factor2 Factor3 Response
        12      10100   0.2     101
        14      10900   -0.7    108
        11      9800    0.8 …
Run Code Online (Sandbox Code Playgroud)

r normalization training-data neural-network

8
推荐指数
1
解决办法
579
查看次数

Xamarin iOS图像在Grid内部重叠

Heyo,

因此,在Xamarin我有一个<Grid><Image>和一对夫妇<Label>的内线吧,都包裹内<ViewCell>.这在Xamarin.Android中看起来完全没问题,但是在Xamarin.iOS中,图像与标签重叠.我不确定它的区别是什么 - 为什么它在Xamarin.Android中看起来不错但在iOS中它的全部都不稳定?

下面是我的XAML和几个模型来展示我的意思.

<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell>
            <ViewCell.View>
            <Grid>
                <Grid.ColumnDefinitions>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Image Grid.Column="0" Grid.Row="0" Aspect="AspectFill" Source="{Binding ImageOverlayEN}" />
                <Label Grid.Column="0" Grid.Row="1" VerticalTextAlignment="Start" LineBreakMode="WordWrap" Text="{Binding DynamicOfferText}" FontSize="18">
                    <Label.FontFamily>
                        <OnPlatform x:TypeArguments="x:String">
                        <OnPlatform.iOS>RobotoCondensed-Regular</OnPlatform.iOS>
                        <OnPlatform.Android>RobotoCondensed-Regular.ttf#RobotoCondensed-Regular</OnPlatform.Android>
                        <OnPlatform.WinPhone>RobotoCondensed-Regular.ttf#RobotoCondensed</OnPlatform.WinPhone>
                    </OnPlatform>
                    </Label.FontFamily>
                </Label>
                <Label Grid.Column="0" Grid.Row="2" VerticalTextAlignment="Start" LineBreakMode="WordWrap" Text="{Binding DynamicOfferDetail}" FontSize="16">
                    <Label.FontFamily>
                        <OnPlatform x:TypeArguments="x:String">
                        <OnPlatform.iOS>RobotoCondensed-Regular</OnPlatform.iOS>
                        <OnPlatform.Android>RobotoCondensed-Regular.ttf#RobotoCondensed-Regular</OnPlatform.Android>
                        <OnPlatform.WinPhone>RobotoCondensed-Regular.ttf#RobotoCondensed</OnPlatform.WinPhone>
                    </OnPlatform>
                    </Label.FontFamily>
                </Label>
                </Grid>
            </ViewCell.View>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

我尝试过设置,HeightRequest但似乎没有什么区别:

#if __IOS__
    if …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios xamarin.android xamarin xamarin.forms

7
推荐指数
1
解决办法
425
查看次数