创建使用XML使用多布局一个textviews款布局、XML、textviews

2023-09-07 03:14:20 作者:温柔尝尽了吗

这是我想创建一个段落我的布局文件。即下一句应该从哪里previous结束点开始。但是,这不会发生,下一句是在下一行的到来。其实我用XML方法去,因为每个句子与数据库相关联,并必须由用户来选择,所以没有选择用做 \\ n

This is my layout file by which I want to create a paragraph. i.e. The next sentence should start from the point where the previous ends up. But this ain't happen and the next sentence is coming in the next line. Actually I am going by an xml approach because each sentence is associated with database and has to be selected by user , so there is no choice by doing it using \n.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <ScrollView
        android:fillViewport="true"
        android:id="@+id/q_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/question_text"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:padding="10dp"
                android:text="Q1 : Select the right sentence out of these ?" />

            <LinearLayout
                android:orientation="vertical"
                android:padding="10dp"
                android:layout_below="@id/question_text"
                android:layout_marginTop="25dp"
                android:id="@+id/comprehension"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/sentence1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Reading comprehension is defined as the level of understanding of a text/message." />

                <TextView
                    android:id="@+id/sentence2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="This understanding comes from the interaction between the words that are written and how they trigger knowledge outside ." />

                <TextView
                    android:id="@+id/sentence3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Proficient reading depends on the ability to recognize words quickly and effortlessly." />

                <TextView
                    android:id="@+id/sentence4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Many educators in the USA believe that students need to learn to analyze text." />

                <TextView
                    android:id="@+id/sentence5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="But other US educators consider this reading approach to be completely backward." />
            </LinearLayout>

            <TextView
                android:id="@+id/explanation_text"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/comprehension"
                android:layout_marginTop="25dp"
                android:padding="10dp"
                android:text="Explanation: Sentence you have selected is right?" />

            <View
                android:visibility="invisible"
                android:id="@+id/user_optionset4"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/explanation_text"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="50dp"
                />
        </RelativeLayout>
    </ScrollView>

    <LinearLayout
        android:background="@android:color/black"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <Button
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:gravity="center"
            android:padding="0dp"
            android:singleLine="true"
            android:text="P"
            android:textColor="@android:color/black" />

        <Button
            android:id="@+id/Take"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.4"
            android:gravity="center"
            android:padding="0dp"
            android:singleLine="true"
            android:text="Done"
            android:textColor="@android:color/white" />

        <Button
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:gravity="center"
            android:padding="0dp"
            android:singleLine="true"
            android:text="N"
            android:textColor="@android:color/black" />
    </LinearLayout>

</RelativeLayout>

这是电流输出:

预期的输出,下一句应该在黄色箭头的位置开始,如显示的图像:

Expected output , the next sentence should start at the position of yellow arrows , as shown in the image :

推荐答案

或许实现,这将是您附加一些CSS到每个句子是一个链接网页视图的最简单的方法,而该链接调用Java方法,将做所需的工作。然后,因为所有的环节都没有阻止,他们将继续在最后一行结束了在那里,没有一个换行符(除非您特别声明的)。

Probably the easiest way of achieving this would be a webview that you attach some css to where each sentence is a link, and that link calls a Java method that will do the desired work. Then since all the links are not blocks, they will continue where the last line ended, without a line break (unless you specifically declare one).

这是如何实现的Java从JS调用的一些信息可以发现here

Some information on how to achieve the calling of Java from js can be found here