本文介绍了TextView 不显示全文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以正常工作的 TextView,但是如果我尝试显示超过 500-600 个符号的文本,它不会显示它们,它只会剪切它们.也按下这两个按钮,它们隐藏而不可见.这是xml

I have a TextView which works normally, but if I try to show text more than 500-600 symbols it doesn't show them, it just cuts them. Also is pushing down these 2 buttons and they are hiding and not visible. This is the xml

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

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="0dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="5dp"
    android:layout_weight="13.07"
    android:background="@drawable/restaurants_buttons"
    android:orientation="vertical" >
    <TextView
       android:id="@+id/name"
       android:layout_width="280dp"
       android:layout_height="wrap_content"
       android:paddingBottom="10dp"
       android:paddingLeft="5dp"
       android:paddingTop="5dp"
       android:text="" />
    <TextView
        android:id="@+id/text"
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:text="" />
    <TextView
        android:id="@+id/rest_id"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:paddingBottom="5dp"
        android:paddingTop="15dp" />


</LinearLayout>

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="fill_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="5dp"
    android:orientation="vertical" >

    <Button
        android:id="@+id/checkMenues"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bg_button"
        android:gravity="center"
        android:padding="4dp"
        android:text="@string/checkMenues" />

    <Button
        android:id="@+id/makeReservation"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bg_button"
        android:gravity="center"
        android:padding="4dp"
        android:text="@string/makeReservation" />
</LinearLayout>

</LinearLayout>

textview 的问题是 android:id="@+id/text"

The problem textview is android:id="@+id/text"

推荐答案

您应该将线性布局包装在滚动布局中.

You should wrap the linear layout in a scroll layout.

像这样:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minHeight="50dp"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="300dp"
            android:layout_height="0dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:layout_weight="13.07"
            android:background="@drawable/restaurants_buttons"
            android:orientation="vertical" >
            <TextView
                android:id="@+id/name"
                android:layout_width="280dp"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="5dp"
                android:paddingTop="5dp"
                android:text="" />
            <TextView
                android:id="@+id/text"
                android:layout_width="280dp"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="5dp"
                android:paddingTop="5dp"
                android:text="" />
            <TextView
                android:id="@+id/rest_id"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:paddingBottom="5dp"
                android:paddingTop="15dp" />


        </LinearLayout>

        <LinearLayout
            android:layout_width="300dp"
            android:layout_height="fill_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <Button
                android:id="@+id/checkMenues"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/bg_button"
                android:gravity="center"
                android:padding="4dp"
                android:text="@string/checkMenues" />

            <Button
                android:id="@+id/makeReservation"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/bg_button"
                android:gravity="center"
                android:padding="4dp"
                android:text="@string/makeReservation" />
        </LinearLayout>

    </LinearLayout>

</ScrollView>

这篇关于TextView 不显示全文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 09:49