HMaster HMaster - 2 months ago 19
Java Question

remove margins around main layout

I'm trying to make a tab widget in android that fills the layout width and is placed directly under the action bar of my activity but the white margins around my tab widget is preventing me from achieving my view, so could anyone please help me to remove these margins (marked by red in the image link below) from around my main relative layout?

Marked white spaces

and following is my xml code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.idm.ui.MainActivity" >

<TabHost
android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:layout_marginTop="-16dp"
android:layout_marginLeft="-15dp"
android:layout_marginRight="-17dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000">

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical|center"
android:showDividers="none" >
</TabWidget>

</LinearLayout>

<LinearLayout
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<RelativeLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ListView
android:id="@+id/elvDownloading"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</RelativeLayout>

<RelativeLayout
android:id="@+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
android:id="@+id/elvDownloaded"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</RelativeLayout>
</FrameLayout>
</LinearLayout>

</LinearLayout>
</TabHost>




thanks in advance

Answer

You should post you layout XML file, but these are most likely the default activity paddings (defined in @dimen/activity_vertical_margin and @dimen/activity_horizontal_margin).

Look for android:padding* or android:margin* values in your layout XML file and set them to 0 or just remove them if not needed.

Edit after the XML was added:

Yes, you should remove these lines:

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"