I have created a relative layout under which i created 3 relative layout
1-for top textviews
2-for buttons at the bottom 3-for he scroll viewnow i want to insert a table below 1st relative layout and above 2nd relative layout,which layout should i use? table has 3 columns first cloumn and secound column as text view and 3rd colums as edit text,the data being displayed on the table is coming from database. so i wanna know which 开发者_StackOverflow中文版layout shall i use? and how can i display the table?
Its better to use LinearLayout
See this
<?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="wrap_content" android:padding="5dp">
<ScrollView android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fadingEdge="none" android:focusable="false">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="*">
<TableRow android:gravity="center" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></TextView>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></EditText>
</TableRow>
<TableRow android:gravity="center" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></TextView>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Series"
android:layout_gravity="center"></EditText>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Note: You can also set width of TextView and EditText and more importantly you can set the gravity and align it accordingly. Also, LinearLayout is useful when you need to add the rows dynamically.It will be useful to you as you are getting the data from database
精彩评论