Как часть одного из представлений в моем приложении, у меня есть место, где пользователи могут выбрать переход на одну из многих других страниц в зависимости от того, какой значок коснулся.Для визуализации этих значков мы используем комбинацию пользовательских значков и библиотеки значков FontAwesome.
Однако на некоторых устройствах, таких как Samsung Galaxy S7, некоторые значки не всегда отображаются должным образом,В частности, один из них отображается с наложением китайского иероглифа.До сих пор мы не могли понять, почему это происходит, поэтому любая помощь будет принята с благодарностью.
Мы используем Xamarin Android и MvvmCross для создания нашего приложения.
Некоторые из представленийкод для основного макета:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
style="@style/RelativeLayoutPageStyle"
android:background="@color/white">
<RelativeLayout
style="@style/RelativeHeader"
android:id="@+id/linearLayout1">
<FontAwesomeIcon
android:id="@+id/flag"
android:layout_alignParentLeft="true"
style="@style/MenuButton" />
<ImageView
android:id="@+id/Header"
style="@style/HeaderLogo"
android:layout_centerInParent="true"
android:src="@drawable/TitleWithIcon" />
<FontAwesomeIcon
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ViewFailedRecordButton"
android:layout_toLeftOf="@+id/ViewAssignmentsButton"
android:layout_toRightOf="@id/Header"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:textColor="#b8860b"
android:text="\uf06a"
android:textSize="16dp"
local:MvxBind="Click ViewFailedRecordsCommand;Visibility BooleanVisibility(FailedRecordsDetected)" />
<FontAwesomeIcon
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ViewAssignmentsButton"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="\uf022"
android:textSize="16dp"
local:MvxBind="Click ViewAssignmentCommand;Visibility BooleanVisibility(HaveAssignmentsForUser);TextColor AssignmentButtonColor, Converter=NativeColor" />
</RelativeLayout>
<LinearLayout
style="@style/CollectionViewHeader"
android:id="@+id/collectionViewHeader"
android:layout_below="@id/linearLayout1"
local:MvxBind="BackgroundColor HeaderBackgroundColor, Converter=NativeColor">
<TextView
android:layout_centerInParent="true"
style="@style/TextViewHeaderResponsive"
local:MvxBind="Text HeaderText" />
</LinearLayout>
<GridView
android:id="@+id/gridView"
android:layout_below="@id/collectionViewHeader"
android:layout_above="@+id/collectionViewFooter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="2" />
<LinearLayout
style="@style/CollectionViewFooter"
android:id="@id/collectionViewFooter"
android:layout_alignParentBottom="true"
local:MvxBind="Visibility HideOnEmptyText(FooterText);BackgroundColor FooterBackgroundColor, Converter=NativeColor;Click FooterClickCommand">
<TextView
android:layout_centerInParent="true"
style="@style/StatusBarFooterTextView"
local:MvxBind="Text FooterText" />
</LinearLayout>
</RelativeLayout>
<MvxListView
android:id="@+id/left_drawer"
style="@style/Menu"
local:MvxItemTemplate="@layout/drawerlistitem"
local:MvxBind="ItemsSource NavigationCellModels" />
</android.support.v4.widget.DrawerLayout>
Представление для шаблона, использованного в вышеупомянутом GridView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
local:MvxBind="Click ClickCommand">
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<FontAwesomeIcon
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="100dp"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
local:MvxBind="Text RecordableDataTypeToIcon(RecordableDataType);Visibility IsRecordableDataTypeFontAwesome(RecordableDataType);TextColor Color, Converter=NativeColor" />
<CbtGlyphIcon
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="100dp"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
local:MvxBind="Text RecordableDataTypeToIcon(RecordableDataType);Visibility IsRecordableDataTypeCbtGlyphValueConverter(RecordableDataType);TextColor Color, Converter=NativeColor" />
</RelativeLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="20sp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
android:maxLines="2"
android:ellipsize="end"
local:MvxBind="Text Title;TextColor Color, Converter=NativeColor" />
</LinearLayout>
Код для класса FontAwesomeIcon:
public class FontAwesomeIcon : TextView
{
private Context _context;
protected FontAwesomeIcon(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
Initialise(null, null);
}
public FontAwesomeIcon(Context context)
: base(context)
{
Initialise(context, null);
}
public FontAwesomeIcon(Context context, IAttributeSet attrs)
: base(context, attrs)
{
Initialise(context, attrs);
}
public FontAwesomeIcon(Context context, IAttributeSet attrs, int defStyle)
: base(context, attrs, defStyle)
{
Initialise(context, attrs);
}
private void Initialise(Context context, IAttributeSet attrs)
{
_context = context ?? Application.Context;
Typeface = Android.Graphics.Typeface.CreateFromAsset(context.Assets, "FontAwesome.otf");
}
}
НаконецВот скриншот того, что я вижу: ![Chinese Character overlapping with FontAwesome Icon](https://i.stack.imgur.com/QbRf7.jpg)