Search code examples
androidandroid-layoutandroid-fragmentsandroid-actionbarandroid-tabhost

Remove Spacing or Padding below Android Tabbed Activity (Action Bar Tabs)


I just created a default "Tabbed Activity - Action Bar Tabs (with ViewPager)" using AndroidStudio

My Question is that - how do I remove the Spacing/Padding on the top while scrolling, but keep the Spacing/Padding at the begining.

Thank You

Screenshot

fragment_main.xml

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView android:id="@+id/section_label" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="...."></TextView>

</ScrollView>

dimens.xml

<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>


Solution

  • Thank you [arpit]

    figured it out Just added some id's

    Now Working

    <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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="0dp"
    tools:context=".MainActivity$PlaceholderFragment">
    
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
    
            <View
                android:id="@+id/v1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/activity_vertical_margin" />
    
            <TextView
                android:id="@+id/section_label"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/v1"
                android:text="..."></TextView>
        </RelativeLayout>
    </ScrollView>