【问题标题】:Unable to fit the large text in table row in TableLayout无法在 TableLayout 中的表格行中容纳大文本
【发布时间】:2014-08-15 19:53:55
【问题描述】:

在 Table 行下的 TableLayout 中,我创建了两个 TextViews,但是当我运行应用程序时,我的文本没有被放入表格列中,而是被超出并且部分文本不可见。

我的安卓代码如下:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/top_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/shadow_layout"
    android:padding="6dip"
    android:layout_margin="10dp">

      <TableLayout
       android:id="@+id/orgSummary_table"
       android:layout_width="wrap_content"

       android:layout_height="wrap_content"
       android:layout_below="@+id/orgSummary_image"
       android:layout_alignStart="@+id/orgSummary_image">

    <TableRow
        android:id="@+id/orgSummary_tb_founded"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/orgSummary_tr1_founded"
            android:textSize="@dimen/subtitle_text"
            android:gravity="top"
            android:text="Founded"
            android:textColor="#d4fff700"
            android:paddingLeft="30dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/orgSummary_tr2_founded"
            android:textSize="@dimen/subtitle_text"
            android:gravity="top"
            android:textColor="#d4fff700"
            android:paddingLeft="50dp"/>

    </TableRow>
    </TableLayout>
    </RelativeLayout>

从我的活动中,我正在调用代码并将文本设置在第二列 ((TextView)findViewById(R.id.orgSummary_tr2_founded)).setText("一些长文本");

但只有部分文字可见

【问题讨论】:

    标签: java android


    【解决方案1】:

    试试

    <TableRow
            android:id="@+id/orgSummary_tb_founded"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp">
    <ScrollView
    android:layout_width="wrap_content"
                android:layout_height="wrap_content"
    >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/orgSummary_tr1_founded"
                android:textSize="@dimen/subtitle_text"
                android:gravity="top"
                android:text="Founded"
                android:textColor="#d4fff700"
                android:paddingLeft="30dp"/>
    </ScrollView>
    
    
        </TableRow>
    

    android:layout_width="match_parent" 用于 TableRow

    【讨论】:

    • 我尝试了选项但没有得到,文本仍然丢失
    • 你的文字不仅仅是屏幕吗?
    • 是的,我想。因为有些文字是不可见的
    • 那么你应该使用滚动视图
    • 在滚动视图中放置任何文本视图
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-08
    • 1970-01-01
    • 1970-01-01
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    相关资源
    最近更新 更多