Is it possible to have two table layout in android UI

你。 提交于 2019-12-25 09:11:06

问题


I need to show two different tables in one UI, i tried for table layout cause it is easy to have table structures through table layout. But i could not have two table layout in one screen. I tried to add the table layout views in a parent layout,e.g Relative or Linear layout, it did not work. Then i tried to add the tables as row in a parent table layout, But nothing is working. It did not show any error or warning while inflating the view, but it just show last table layout only. Is it not possible to have two table layout in one screen.


回答1:


Wrap the two TableLayouts in a LinearLayout and define android:layout_weight on the TableLayouts:

<?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:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="#ff0000" >     
</TableLayout>

<TableLayout
    android:id="@+id/tableLayout2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="#00ff00"  >     
</TableLayout>



来源:https://stackoverflow.com/questions/7915624/is-it-possible-to-have-two-table-layout-in-android-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!