Android 文本视图文本更改时按钮消失

Android 文本视图文本更改时按钮消失,android,android-layout,size,textview,android-button,Android,Android Layout,Size,Textview,Android Button,我的布局有问题。我有一个文本视图,可以在你回答问题时更改文本。所有的问题文本和答案文本都在一个在线数据库中,我已经正确下载了所有文本 问题是,当你正确回答一个问题时,你必须改变问题文本和答案文本。有时它做得很好,但有时答案按钮消失了 有人能帮我吗?我把代码放在下面: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://s

我的布局有问题。我有一个文本视图,可以在你回答问题时更改文本。所有的问题文本和答案文本都在一个在线数据库中,我已经正确下载了所有文本

问题是,当你正确回答一个问题时,你必须改变问题文本和答案文本。有时它做得很好,但有时答案按钮消失了

有人能帮我吗?我把代码放在下面:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context="com.prodintec.am_motion.QuizActivity">

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

    <TextView
        android:id="@+id/HeaderTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20dp"
        android:text="FOUR OPTIONS QUESTION"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true" />

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="20dp"
        android:paddingEnd="10dp"
        android:paddingStart="10dp"
        android:layout_below="@+id/HeaderTextView"
        android:layout_alignParentStart="true">


        <TableRow
            android:padding="2dp"
            android:id="@+id/tableRow2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/answer1"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:layout_gravity="center"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_marginBottom="2dp"
                android:background="@color/primary"
                android:textColor="@color/accent"
                android:textSize="10dp"
                android:text="ANSWER 1" />

            <Button
                android:id="@+id/answer2"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:layout_gravity="center"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_marginBottom="2dp"
                android:background="@color/primary"
                android:textColor="@color/accent"
                android:textSize="10dp"
                android:text="ANSWER 2" />
        </TableRow>

        <TableRow
            android:padding="2dp"
            android:id="@+id/tableRow3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/answer3"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:layout_gravity="center"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_marginBottom="2dp"
                android:background="@color/primary"
                android:textColor="@color/accent"
                android:textSize="10dp"
                android:text="ANSWER 3" />

            <Button
                android:id="@+id/answer4"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:layout_gravity="center"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_marginBottom="2dp"
                android:background="@color/primary"
                android:textColor="@color/accent"
                android:textSize="10dp"
                android:text="ANSWER 4" />
        </TableRow>

        <TableRow
            android:padding="2dp"
            android:id="@+id/tableRow4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/HeaderTextView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="SEE ACRONYM BUTTON FOR MORE INFORMATION" />
        </TableRow>
    </TableLayout>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingStart="10dp">

        <TableRow
            android:padding="2dp"
            android:id="@+id/tableRow6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/acronism"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:padding="5dp"
                android:background="@color/primary"
                android:textColor="@color/accent"
                android:textSize="20dp"
                android:text="ACRONYM" />
        </TableRow>
    </TableLayout>

    <TextView
        android:id="@+id/PointsTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:padding="5dp"
        android:text="POINTS:  "
        android:textAlignment="textEnd" />
</RelativeLayout>

</android.support.constraint.ConstraintLayout>

第二项不是:

我认为重要的是,这个问题只在我第一次将textview放入tablelayout时发生,因为我更改了布局,但是在屏幕限制附近剪切文本时会出现大小问题。通过这种新的布局,我解决了这个问题,但我现在遇到了另一个问题。

试试这个,我的朋友

<?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:orientation="vertical">

<ScrollView
    android:layout_width="match_parent"
    android:fillViewport="true"
    android:layout_height="match_parent">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/HeaderTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:text="FOUR OPTIONS QUESTIOgfgfdgdfgdfhghdfghdfjghjdfhgjdfhgjkhdfjghjdfjhgjdhfgjfhddgjhdfjghdjfghjdfhgjfdhgjhdfjghfdjghfdjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjheuireuiwN"
        android:textSize="20dp" />

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/HeaderTextView"
        android:paddingEnd="10dp"
        android:paddingStart="10dp"
        android:paddingTop="20dp">


        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp">

            <Button
                android:id="@+id/answer1"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="ANSWER 1"
                android:textSize="10dp" />

            <Button
                android:id="@+id/answer2"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="ANSWER 2"
                android:textSize="10dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp">

            <Button
                android:id="@+id/answer3"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="ANSWER 3"
                android:textSize="10dp" />

            <Button
                android:id="@+id/answer4"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_weight="1"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="ANSWER 4"
                android:textSize="10dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp">

            <TextView
                android:id="@+id/HeaderTextView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="SEE ACRONYM BUTTON FOR MORE INFORMATION" />
        </TableRow>
    </TableLayout>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingStart="10dp">

        <TableRow
            android:id="@+id/tableRow6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp">

            <Button
                android:id="@+id/acronism"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:padding="5dp"

                android:text="ACRONYM"
                android:textSize="20dp" />
        </TableRow>
    </TableLayout>

    <TextView
        android:id="@+id/PointsTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:padding="5dp"
        android:text="POINTS:  "
        android:textAlignment="textEnd" />
</RelativeLayout>
</ScrollView>
</LinearLayout>


仅使用线性布局而不是相对布局]我现在使用线性布局,它会一直延伸到屏幕的右边框:/能否粘贴要创建的布局的图像,以便我向您发送代码design@NileshRathod我想要我的问题上的设计,但在文本更改时不要松开按钮。你能做到吗?谢谢第一个图像…?我使用这个布局,有更多的问题和答案,我有一个问题。当textview或按钮的文本长度超过3行时,它只写入前三行,但缺少下一行。你能再帮我一次吗@尼利斯·拉托德