Как отформатировать огромное текстовое представление? - PullRequest
0 голосов
/ 27 октября 2019

Я хочу создать приложение, в котором есть история, с абзацами, диалогами и заголовками. Как я могу сделать это без использования HTML-тегов в Strings.xml? Есть ли способ отформатировать это, просто используя TextView внутри ScrollView (потому что это единственный известный мне способ) в Activity_main.xml?

Ответы [ 2 ]

0 голосов
/ 28 октября 2019

Вот пример

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="25sp"
        android:textStyle="bold|italic"
        android:text="Title"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="The point is, that's 20 minutes of your life you'll never get back. And here’s the really sobering statistic: If you want to be 99% certain of getting just one response – just one! – be prepared to send out 114 messages.

That’s one of the reasons OkCupid users exchange about 4 million messages – a day. That's roughly 166,666 messages being sent every hour – one of which was yours. And that’s just one site.

Think of all the Tinder, Bumble, Match.com etc… messages flying around out there. Your message has a lot of competition – especially when you’re messaging the most attractive local women.

No wonder online dating can quickly turn into the most frustrating part-time job you’ll ever have!

Let's assume the initial hurdles standing between you and meeting your ideal partner have been cleared – you've chosen a dating site, written an engaging profile, and selected the perfect profile picture.

You’re ready to skip all that frustration and wasted time, and start using cut  paste messages that will get you real results fast."/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Anytime you can find a way to establish common ground, jump on the opportunity. Studies have shown that people are more comfortable around those who remind them of themselves, and if she’s more likely to respond if she feels a bond with you right off the bat.

Connecting over the shared experience of using dating sites is one way to do it. You could also create a message built around cooking, swimming, dancing, reading – whatever subjects you have in common with your target woman.

Some dating sites like Match.com allow you to do keyword searches, so you can filter specifically for women who enjoy a particular hobby."/>
    </LinearLayout>

</LinearLayout>

Примечание: поместите ваш текст в string.xml и назовите его следующим образом android:text="@string/your_text" вместо непосредственного ввода.

0 голосов
/ 28 октября 2019

Итак, если мне нужно написать огромный текст (например, 20 страниц), мне придется использовать HTML?

...