所以我正在开发一个Xamarin.Forms项目,我想为Entry Class创建一个自定义渲染器,只在条目底部添加一个边框。我已完成此部分,但后来意识到Xamarin.Forms不会自动将文本垂直居中于条目中。但是,当我添加此功能时,包含Entries的页面将不再加载。
这是我的渲染器代码
using Xamarin.Forms.Platform.Android;
using HuntFishNy.Droid.Renderer;
using Xamarin.Forms;
using HuntFishNy.Views;
[assembly: ExportRenderer(typeof(BottomBorderEntry),typeof(BottomBorderEntryRenderer))]
namespace HuntFishNy.Droid.Renderer
{
class BottomBorderEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Background = Resources.GetDrawable(Resource.Drawable.BottomBorderRectangle);
Control.SetForegroundGravity(Android.Views.GravityFlags.CenterVertical);
}
}
}
}
作为参考,我正在XAML中完成所有布局工作,底部边框的位工作正常。只要我忽略了设定引力的线,一切都有效。
此外,这是在调试控制台中打印出来的内容,如果它有帮助的话
07-01 11:33:45.971 D / Mono(22308):装配装载机探测位置:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖< /strong>/HuntFishNY.dll' ;. 07-01 11:33:45.981 D / Mono(22308):图像addref HuntFishNy [0x96ab1880] - &gt; /storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll[0x9b32ae00]:2 07-01 11:33:45.981 D / Mono(22308):装配装载机从位置加载装配:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.981 D / Mono(22308):配置尝试解析:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNy.dll.config' ;. 07-01 11:33:45.981 D / Mono(22308):配置尝试解析:&#39; / Users / builder / data / lanes / 2923/52635947 / source / monodroid / builds / install / mono-armv7 / etc /mono/assemblies/HuntFishNy/HuntFishNy.config' ;. 07-01 11:33:45.981 D / Mono(22308):卸载图像/storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll [0x9b32ae00] 。 07-01 11:33:45.981 D / Mono(22308):装配装载机探测位置:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.981 D / Mono(22308):图像addref HuntFishNy [0x96ab1940] - &gt; /storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll[0x9b32ae00]:2 07-01 11:33:45.981 D / Mono(22308):装配装载机从位置加载装配:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.981 D / Mono(22308):配置尝试解析:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNy.dll.config' ;. 07-01 11:33:45.981 D / Mono(22308):配置尝试解析:&#39; / Users / builder / data / lanes / 2923/52635947 / source / monodroid / builds / install / mono-armv7 / etc /mono/assemblies/HuntFishNy/HuntFishNy.config' ;. 07-01 11:33:45.981 D / Mono(22308):卸载图像/storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll [0x9b32ae00] 。 07-01 11:33:45.991 D / Mono(22308):装配装载机探测位置:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):图像addref HuntFishNy [0x96ab18e0] - &gt; /storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll[0x9b32ae00]:2 07-01 11:33:45.991 D / Mono(22308):装配装载机从位置加载装配:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNy.dll.config' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; / Users / builder / data / lanes / 2923/52635947 / source / monodroid / builds / install / mono-armv7 / etc /mono/assemblies/HuntFishNy/HuntFishNy.config' ;. 07-01 11:33:45.991 D / Mono(22308):卸载图像/storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll [0x9b32ae00] 。 07-01 11:33:45.991 D / Mono(22308):装配装载机探测位置:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):图像addref HuntFishNy [0x96ab1880] - &gt; /storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll[0x9b32ae00]:2 07-01 11:33:45.991 D / Mono(22308):装配装载机从位置加载装配:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNy.dll.config' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; / Users / builder / data / lanes / 2923/52635947 / source / monodroid / builds / install / mono-armv7 / etc /mono/assemblies/HuntFishNy/HuntFishNy.config' ;. 07-01 11:33:45.991 D / Mono(22308):卸载图像/storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll [0x9b32ae00] 。 07-01 11:33:45.991 D / Mono(22308):装配装载机探测位置:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):图像addref HuntFishNy [0x96ab1940] - &gt; /storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll[0x9b32ae00]:2 07-01 11:33:45.991 D / Mono(22308):装配装载机从位置加载装配:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNY.dll' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; /storage/emulated/0/Android/data/HuntFishNy.Droid/files /。覆盖 /HuntFishNy.dll.config' ;. 07-01 11:33:45.991 D / Mono(22308):配置尝试解析:&#39; / Users / builder / data / lanes / 2923/52635947 / source / monodroid / builds / install / mono-armv7 / etc /mono/assemblies/HuntFishNy/HuntFishNy.config' ;. 07-01 11:33:45.991 D / Mono(22308):卸载图像/storage/emulated/0/Android/data/HuntFishNy.Droid/files/.override/HuntFishNY.dll [0x9b32ae00] 。 07-01 11:33:55.252 D / Mono(22308):[0x9beb5100]工人完成
答案 0 :(得分:0)
var firstName = "Peter",
lastName = "Ally";
function showFullName () {
alert (window.firstName + " " + window.lastName);
}
showFullName();