小编Max*_*mus的帖子

如何更改StateListDrawable中的颜色?

我有一个按钮的下面的选择器(有2个状态,常规和按下):

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
 <shape>
  <solid
      android:color="#3498DB" />
  <stroke
      android:width="1dp"
      android:color="#2980B9" />
  <corners
      android:radius="0dp" />
  <padding
      android:left="12dp"
      android:top="12dp"
      android:right="12dp"
      android:bottom="12dp" />
 </shape>
</item>
<item>
 <shape>
  <solid
      android:color="#2980B9" />
  <stroke
      android:width="1dp"
      android:color="#2980B9" />
  <corners
      android:radius="0dp" />
  <padding
      android:left="12dp"
      android:top="12dp"
      android:right="12dp"
      android:bottom="12dp" />
 </shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)

我的按钮具有以下内容,它将背景指定为上面的选择器:

<Button
  android:id="@+id/button_LaunchShiftsGame"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="@string/ShiftsMode"
  android:background="@drawable/selector_Button"
  style="@style/Button_Text" />
Run Code Online (Sandbox Code Playgroud)

我需要在Activity加载时从代码访问和更改两种状态的颜色.

我怎样才能做到这一点?

android android-ui android-layout xamarin.android xamarin

12
推荐指数
1
解决办法
5096
查看次数

UWP成分Api是否支持颜色替换?

我一直在尝试寻找与颜色替换相关的示例,这里是一个使用Photoshop的例子,例如,可以采用蓝色阴影并用红色阴影替换它:

之前: 在此输入图像描述

后: 在此输入图像描述

这是否可以使用最新版本的Composition Api中的Composition Effects?

我见过与Hue Rotations,Temperature和Tint有关的例子:

https://xamlbrewer.wordpress.com/2016/04/08/uwp-composition-effects-hue-rotation/

https://xamlbrewer.wordpress.com/2016/04/19/uwp-composition-effects-temperature-and-tint/

但我想知道api是否能够使用Effects来切换图像中的颜色范围?

c# uwp xaml-composition windows-composition-api

11
推荐指数
1
解决办法
466
查看次数

如何在Drawable中更改形状颜色?

我有以下按钮:

<Button
    android:id="@+id/Button_Collect"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_marginBottom="16dp"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/CollectButtonShape" />
Run Code Online (Sandbox Code Playgroud)

看起来像这样:

在此输入图像描述

其中包括以下背景drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
  <shape android:innerRadius="0dp" android:shape="ring" android:thicknessRatio="2" android:useLevel="false" >
    <solid android:color="@android:color/transparent" />

    <stroke
        android:width="2dp"
        android:color="#FF27AE60" />
  </shape>
</item>
<item android:top="10dp" android:left="10dp" android:right="10dp" android:bottom="10dp">
    <shape android:shape="oval">
        <solid android:color="#FF27AE60" />
    </shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

如何以编程方式更改环和内圈的颜色(我需要在Touch事件中执行此操作)???

android xamarin.android xamarin android-drawable

6
推荐指数
1
解决办法
4029
查看次数

引用ReactiveUI 7.4时iOS启动错误

我有一个带有.Net Standard 1.4核心库的Xamarin Forms项目,它包含所有代码.我在核心和iOS项目中都引用了ReactiveUI 7.4.但是当我在iOS模拟器上编译并运行时,我在应用程序启动时收到以下错误:

2017-08-24 13:39:39.040 TestProject.iOS[25074:307385] Could not register the assembly 'ReactiveUI': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/corlib/System.Reflection/Assembly.cs:410 
  at Registrar.DynamicRegistrar.CollectTypes (System.Reflection.Assembly assembly) [0x00000] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:237 
  at Registrar.Registrar.RegisterAssembly (System.Reflection.Assembly assembly) [0x00056] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/ObjCRuntime/Registrar.cs:1978 


Loaded assembly: /Library/Frameworks/Xamarin.Interactive.framework/Versions/Current/Agents/iOS/Xamarin.Interactive.iOS.dll [External]
Loaded assembly: /Library/Frameworks/Xamarin.Interactive.framework/Versions/Current/Agents/iOS/Xamarin.Interactive.dll [External]
Unhandled Exception:

System.BadImageFormatException: <Timeout exceeded getting exception details>
Run Code Online (Sandbox Code Playgroud)

Unhandled Exception:
System.BadImageFormatException: Could not resolve field token 0x040000fd
File name: 'ReactiveUI'
  at TestProject.iOS.AppDelegate..ctor () …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios reactiveui xamarin xamarin.forms

6
推荐指数
1
解决办法
432
查看次数

C#与基于列表的属性相等

我在C#中读过很多与正确相等有关的文章:

http://www.loganfranken.com/blog/687/overriding-equals-in-c-part-1/

重写System.Object.GetHashCode的最佳算法是什么?

假设以下示例类:

public class CustomData
{
    public string Name { get; set;}

    public IList<double> Values = new List<double>();
}
Run Code Online (Sandbox Code Playgroud)

是否仍然需要使用.Equals()来比较Values属性?这是我的意思的完全相等的样本:

#region Equality

    public override bool Equals(object value)
    {
        if(Object.ReferenceEquals(null, value)) return false;   // Is null?
        if (Object.ReferenceEquals(this, value)) return true;   // Is the same object?
        if (value.GetType() != this.GetType()) return false;    // Is the same type?

        return IsEqual((CustomData)value);
    }

    public bool Equals(CustomData obj)
    {
        if (Object.ReferenceEquals(null, obj)) return false;    // Is null?
        if (Object.ReferenceEquals(this, …
Run Code Online (Sandbox Code Playgroud)

.net c#

5
推荐指数
1
解决办法
79
查看次数

如何在Windows UWP中实现自定义演示者(Xamarin,MvvmCross)

我的Android应用程序中有以下代码,它基本上使用一个页面(使用NavigationDrawer)并将片段交换到中心视图中.这允许导航在一个页面而不是许多页面上进行:

Setup.cs:

    protected override IMvxAndroidViewPresenter CreateViewPresenter()
    {
        var customPresenter = new MvxFragmentsPresenter();
        Mvx.RegisterSingleton<IMvxFragmentsPresenter>(customPresenter);
        return customPresenter;
    }
Run Code Online (Sandbox Code Playgroud)

ShellPage.cs

    public class ShellPage : MvxCachingFragmentCompatActivity<ShellPageViewModel>, IMvxFragmentHost
    {
        .
        .
        .

        public bool Show(MvxViewModelRequest request, Bundle bundle)
        {
            if (request.ViewModelType == typeof(MenuContentViewModel))
            {
                ShowFragment(request.ViewModelType.Name, Resource.Id.navigation_frame, bundle);
                return true;
            }
            else
            {
                ShowFragment(request.ViewModelType.Name, Resource.Id.content_frame, bundle, true);
                return true;
            }
        }

        public bool Close(IMvxViewModel viewModel)
        {
            CloseFragment(viewModel.GetType().Name, Resource.Id.content_frame);
            return true;
        }

        .
        .
        .
    }
Run Code Online (Sandbox Code Playgroud)

如何在Windows UWP应用程序中实现相同的行为?或者更确切地说,是否存在实现CustomPresenter的Windows MvvmCross应用程序的任何示例?这至少可以让我了解如何实现它.

谢谢!

更新:

我终于开始弄明白如何与客户主持人讨论这个问题了:

    public class CustomPresenter : IMvxWindowsViewPresenter …
Run Code Online (Sandbox Code Playgroud)

mvvmcross xamarin uwp

4
推荐指数
1
解决办法
1717
查看次数

我无法获得正确的 StoreContext

我已将我的应用程序提交到 Windows 应用商店并通过了认证。根据测试说明:

https://learn.microsoft.com/en-us/windows/uwp/monetize/in-app-purchases-and-Trials#in-app-purchases-and-Trials-using-the-windowsservicesstore-namespace

我已将该应用程序发布为隐藏应用程序。我还将该应用程序关联到商店:

在此输入图像描述

当我调试我的应用程序时,我从未获得正确的 StoreContext 实例。我有以下错误:

在此输入图像描述

根据上面的文档链接,这是我遇到的问题:

如果您未将项目与应用商店中的应用程序关联,StoreContext 方法会将其返回值的 ExtendedError 属性设置为错误代码值 0x803F6107。该值表示应用商店对应用程序一无所知。

如何让我的应用程序(或 Visual Studio)了解我的商店状态?

windows-store windows-store-apps uwp

4
推荐指数
1
解决办法
853
查看次数

Visual Studio无法识别MvxFragment的BindingInflate函数

我有以下课程:

using Cirrious.MvvmCross.Binding.BindingContext;
using Cirrious.MvvmCross.Droid.Views;
using Cirrious.MvvmCross.Droid.Fragging;
using Cirrious.MvvmCross.Droid.Fragging.Fragments;

public class DifficultyItemFragment : MvxFragment
{
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        var ignored = base.OnCreateView(inflater, container, savedInstanceState);
        return this.BindingInflate(Resource.Layout.DifficultyItemFragment, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

 Error  8   ...'QuickShift.Android.Views.DifficultyItemFragment' does not contain a definition for 'BindingInflate' and no extension method 'BindingInflate' accepting a first argument of type 'QuickShift.Android.Views.DifficultyItemFragment' could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我查看了MvvmCross源代码,BindingInflate确实存在于BindingContext命名空间中.

我错过了什么?我引用了所有必需的库,包括Xamarin.Android.Support.v4

在此输入图像描述

更新:

我在VS 2013中创建了一个示例项目来说明问题.您会注意到在Fragment1.cs中存在同样的问题:

示例应用

c# android xamarin.android mvvmcross xamarin

3
推荐指数
1
解决办法
1244
查看次数

可绘制四色边框

是否可以使用Layer-List实现以下作为drawable(用于背景)?

在此输入图像描述

谢谢!

android android-ui android-layout android-drawable

2
推荐指数
1
解决办法
224
查看次数

MvvmCross,如何在另一个程序集中注册Service?

我在PCL中有一个名为MyProject.Core的“ Core”项目,该项目具有:

     public interface IPhotoService
Run Code Online (Sandbox Code Playgroud)

然后,我创建一个名为MyProject.Core.Android的Android类库项目,并从nuget 添加MvvmCross Core的引用。现在,通过执行此操作,我现在知道我的Android类库没有“ setup.cs”。

MyProject.Core.Android中,我希望该服务(特定于android)如下:

    public class PhotoService : IPhotoService
Run Code Online (Sandbox Code Playgroud)

在我的Android UI项目中,我的Setup.cs包含以下内容:

    public override void Initialize()
    {
        CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();
    }
Run Code Online (Sandbox Code Playgroud)

如果我的PhotoService注册存在于没有Setup.cs 的程序集MyProject.Core.Android中,该如何注册?

c# android inversion-of-control mvvmcross xamarin

2
推荐指数
1
解决办法
586
查看次数