英文:
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行,但是我看不出有什么问题。也许是因为 '<' 符号,但我不太清楚。有没有一种替代的方法来写这个符号?
英文:
<?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>
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 "<"
with "&lt;"
it should work
Here are more symbols to work with:
https://www.w3.org/TR/html4/sgml/entities.html
英文:
Replace "<"
with "&lt;"
it should work
Here are more symbols to work with:
https://www.w3.org/TR/html4/sgml/entities.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论