【问题标题】:How to define column width of TableLayout in my case?在我的情况下如何定义 TableLayout 的列宽?
【发布时间】:2011-07-06 12:20:45
【问题描述】:

我有一个表格布局:

<TABLELAYOUT xmlns:android="http://schemas.android.com/apk/res/android"      

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

   <TABLEROW>
       <TEXTVIEW 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="1">

        <TEXTVIEW 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="2">

         <TEXTVIEW 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="3">

         <TEXTVIEW 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="4">
          ...
          <!--there are 10 columns-->
          ...
    </TABLEROW>
</TABLELAYOUT>

此表中有 10 列。

我的问题是:

  1. 如何自定义每个列宽,以便屏幕上只显示 4 列??

  2. 如何设置行高?

【问题讨论】:

    标签: android android-layout android-emulator android-widget


    【解决方案1】:

    你可以通过(screenWidth/4)定义前4个textView的大小。另外6个你喜欢。所以你只会看到前4列

    【讨论】:

    • @Rasel ,我的观点是如何定义每列的宽度?我不希望每一列总是有文本视图的换行宽度。
    • 每个 textView 都是一列,因为您将它添加到 tableRow。
    • 对于前 4 个 TextView 使用 android:layout_width="80px"。看看结果。你会明白该怎么做
    • 很高兴它帮助了你
    猜你喜欢
    • 2020-04-27
    • 2016-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-16
    • 2015-02-09
    • 2013-10-28
    • 1970-01-01
    相关资源
    最近更新 更多