Android EmojiCompat无法在旧版本上显示一些表情符号

时间:2018-06-24 13:56:14

标签: android xamarin.android emoji

我在Android应用程序中使用了一些表情符号(例如map)。不出所料,其中一些可以在api 25上显示,但不会更早。我正在尝试EmojiCompat,但没有成功。可以在普通的textview中显示的表情符号可以在EmojiAppCompatTextView中显示(请参阅Api 25)。无法与普通表情符号一起显示的表情符号仍不能与EmojiCompat显示(请参阅Api 19)。

enter image description here

enter image description here

Goolge Play服务是API 19模拟器上的最新版本。如屏幕截图所示,无法显示表情符号图和标签。我想emojicompat用于在api 19及更高版本上显示设备上所有受支持的emoji。捆绑软件和下载字体均已尝试。

我正在使用从https://github.com/xamarin/monodroid-samples/tree/master/android-o/EmojiCompat移植的Xamarin EmojiCompat示例https://github.com/googlesamples/android-EmojiCompat对其进行测试。

我添加了几行以包含普通的textview和我正在使用的表情符号:

[Activity(Label = "EmojiCompat", MainLauncher = true, WindowSoftInputMode = Android.Views.SoftInput.StateUnchanged)]
public class MainActivity : AppCompatActivity
{
    const string emojiStringMoneyBag = "\uD83D\uDCB0";
    const string emojiStringLabel = "\uD83C\uDFF7";
    const string emojiStringMap = "\uD83D\uDDFA";

    // [U+1F469] (WOMAN) + [U+200D] (ZERO WIDTH JOINER) + [U+1F4BB] (PERSONAL COMPUTER)
    const string WomanTechnologist = "\uD83D\uDC69\u200D\uD83D\uDCBB";

    // [U+1F469] (WOMAN) + [U+200D] (ZERO WIDTH JOINER) + [U+1F3A4] (MICROPHONE)
    const string WomanSinger = "\uD83D\uDC69\u200D\uD83C\uDFA4";

    string Emoji = WomanTechnologist + " " + WomanSinger + " " + emojiStringMoneyBag + " " + emojiStringMap + " " + emojiStringLabel;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        SetContentView(Resource.Layout.activity_main);

        //string emojiStringLabel = char.ConvertFromUtf32(0x0001F3F7);
        //string Emoji = WomanTechnologist + " " + WomanSinger + " " + emojiStringAddress + " " + emojiStringLabel + " " + emojiStringMoneyBag;

        var textView = (TextView)FindViewById(Resource.Id.text_view);
        textView.Text = "Ordinary textview" +  Emoji;

        // TextView variant provided by EmojiCompat library
        var emojiTextView = (TextView) FindViewById(Resource.Id.emoji_text_view);
        emojiTextView.Text = GetString(Resource.String.emoji_text_view, Emoji);


        // EditText variant provided by EmojiCompat library
        var emojiEditText = (TextView) FindViewById(Resource.Id.emoji_edit_text);
        emojiEditText.Text = GetString(Resource.String.emoji_edit_text, Emoji);

        // Button variant provided by EmojiCompat library
        var emojiButton = (TextView) FindViewById(Resource.Id.emoji_button);
        emojiButton.Text = GetString(Resource.String.emoji_button, Emoji);

        // Regular TextView without EmojiCompat support; you have to manually process the text
        var regularTextView = (TextView) FindViewById(Resource.Id.regular_text_view);
        var textToShow = GetString(Resource.String.regular_text_view, Emoji);
        EmojiCompat.Get().RegisterInitCallback(new InitCallbackImpl 
        {
            RegularTextView = regularTextView,
            Text = textToShow
        });

        // Custom TextView
        var customTextView = (TextView) FindViewById(Resource.Id.emoji_custom_text_view);
        customTextView.Text = GetString(Resource.String.custom_text_view, Emoji);
    }


<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/spacing_normal">
      <TextView
          android:id="@+id/text_view"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="@dimen/spacing_small"
          android:textSize="@dimen/text_size" />
      <android.support.text.emoji.widget.EmojiAppCompatTextView
            android:id="@+id/emoji_text_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/spacing_small"
            android:textSize="@dimen/text_size" />

我的考试中是否缺少任何内容?

谢谢

尼克

0 个答案:

没有答案