Reputation: 3513
I want to show table and below that table i want to show button in center of the table layout, so i wrap the both in linear layout but now it doesn't display. please help me to solve the problem. this is my xml layout file=-
<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>
Upvotes: 0
Views: 364
Reputation: 1986
Is there a reason why you don't use a 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>
this way it should adapt nicely inside the layout.
If your problem is that you don't SEE the button,maybe your table is too big?You should make it smaller,or put everything inside a nice ScrollView
Upvotes: 2
Reputation: 5869
add android:gravity = "center_horizontal" to the Linear Layout and set orientation of LinearLayout as Vertical.
Upvotes: 0
Reputation: 2127
add scrollView as parent:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
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>
</Scrollview>
Upvotes: 0