csh_34 2012-09-18 09:03 采纳率: 0%
浏览 3320
已结题

在Android中如何实现下面这个布局?

data1    hello   hi 
data2    hello2  hi
data3    hi      Hello

我想知道用TableLayout还是linearLayout或者RelativeLayout,哪一个视图可以很好的实现这个布局?我也想用xml代码实现这个布局,请求各位支招,万分感谢!

  • 写回答

4条回答

  • myc_100 2012-09-18 09:44
    关注

    给出这段代码,看看能否实现想要的布局:

     <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="fill_parent"
     android:layout_height="fill_parent">
    <TableLayout android:layout_width="fill_parent"
     android:layout_height="wrap_content">
     <TableRow android:weightSum="3">
     <TextView android:layout_weight="1" android:layout_width="wrap_content"
     android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
     android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
     android:layout_height="wrap_content" android:text="hello" />
    </TableRow>
    <TableRow android:weightSum="3">
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    </TableRow>
    <TableRow android:weightSum="3">
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="hello" />
    </TableRow>
    </TableLayout>
    </LinearLayout>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试