O_Casper_ne 2013-03-25 08:20 采纳率: 7.7%
浏览 4450
已采纳

在linear layout添加按钮时,按钮不可见

我想显示一个表格,然后在那个表格下面的表格布局的中间显示按钮。然后把它们放在 linear 布局中,但是不能显示。如何解决这个问题呢?下面是 xml 布局文件:

<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dip"
        android:layout_marginTop="30dp"
        android:layout_toRightOf="@id/item">
    <TableLayout
        android:id="@+id/itemTable"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/border"
        android:orientation="horizontal"
        android:padding="3dip" >
    </TableLayout>

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@drawable/list_selector"
        android:padding="10dp" 
        android:layout_gravity="center_horizontal"
        android:text=" Order " />
</LinearLayout>
  • 写回答

2条回答

  • xiaoyan_12 2013-03-26 02:49
    关注

    你应该使用一个 RelativeLayout:

    <RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dip"
        android:layout_marginTop="30dp"
        android:layout_toRightOf="@id/item">
    <TableLayout
        android:id="@+id/itemTable"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="@drawable/border"
        android:orientation="horizontal"
        android:padding="3dip" >
    </TableLayout>
    
    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@drawable/list_selector"
        android:padding="10dp" 
        android:layout_below="@+id/itemTable"
        android:layout_gravity="center_horizontal"
        android:text=" Order " />
     </RelativeLayout>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大