在Android Studio中将文本设置为'<‘是否有解决方法?

huangapple go评论87阅读模式
英文:

is there a solve for setting text to : '<' in android studio?

问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/uibackground"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="5dp"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/previousButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/buttonstyles"
            android:text="<"
            android:textSize="40dp"
            android:textStyle="bold" />

        <TextSwitcher
            android:id="@+id/textSwitcher"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:background="@drawable/buttonstyles"
            android:inAnimation="@android:anim/slide_in_left"
            android:outAnimation="@android:anim/slide_out_right" />

        <Button
            android:id="@+id/nextButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/buttonstyles"
            android:text=">"
            android:textSize="40dp"
            android:textStyle="bold" />
    </LinearLayout>

</LinearLayout>

当我运行应用程序时,我得到了这个错误:
activity_main.xml:25: AAPT: error: not well-formed (invalid token)。

我检查了第25行,但是我看不出有什么问题。也许是因为 '<' 符号,但我不太清楚。有没有一种替代的方法来写这个符号?

英文:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:background=&quot;@drawable/uibackground&quot;
    android:gravity=&quot;center&quot;
    android:orientation=&quot;vertical&quot;
    android:padding=&quot;5dp&quot;
    tools:context=&quot;.MainActivity&quot;&gt;


    &lt;LinearLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;60dp&quot;
        android:orientation=&quot;horizontal&quot;&gt;

        &lt;Button
            android:id=&quot;@+id/previousButton&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;match_parent&quot;
            android:layout_weight=&quot;1&quot;
            android:background=&quot;@drawable/buttonstyles&quot;
            android:text=&quot;&lt;&quot;
            android:textSize=&quot;40dp&quot;
            android:textStyle=&quot;bold&quot; /&gt;

        &lt;TextSwitcher
            android:id=&quot;@+id/textSwitcher&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;match_parent&quot;
            android:layout_weight=&quot;2&quot;
            android:background=&quot;@drawable/buttonstyles&quot;
            android:inAnimation=&quot;@android:anim/slide_in_left&quot;
            android:outAnimation=&quot;@android:anim/slide_out_right&quot; /&gt;

        &lt;Button
            android:id=&quot;@+id/nextButton&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;match_parent&quot;
            android:layout_weight=&quot;1&quot;
            android:background=&quot;@drawable/buttonstyles&quot;
            android:text=&quot;&gt;&quot;
            android:textSize=&quot;40dp&quot;
            android:textStyle=&quot;bold&quot; /&gt;
    &lt;/LinearLayout&gt;


&lt;/LinearLayout&gt;

when i run app i get this error:
activity_main.xml:25: AAPT: error: not well-formed (invalid token).

i checked 25th line but, i couldn't see a problem. maybe it's because of '<' sign but i don't know. is there an alternative method to write this sign?

答案1

得分: 0

Replace &quot;&lt;&quot; with &quot;&amp;lt;&quot;
it should work

Here are more symbols to work with:
https://www.w3.org/TR/html4/sgml/entities.html

英文:

Replace &quot;&lt;&quot; with &quot;&amp;lt;&quot;
it should work

Here are more symbols to work with:
https://www.w3.org/TR/html4/sgml/entities.html

huangapple
  • 本文由 发表于 2020年8月23日 18:37:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/63545966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定