how remove margin from right and left of list fragment in android

72 Views Asked by At

i have one list fragment but i have 2 problem

1- there is margin in right and left side and list view width is not match parent

2-scroll bar is in list view not out .

i tested these codes in main activity too but no use

  ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getListView()
            .getLayoutParams();
   getListView().setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY );
    layoutParams.setMargins(0, 0, 0, 0);
    getListView().addHeaderView(headerView);
    newadp = new adveradapter(getActivity(), Const.advermodel);
    setListAdapter(newadp);

    getListView().setOnScrollListener(this);
    getListView().setDivider(null);
    getListView().setDividerHeight(16);

/////// my row design code that is set in adapter is here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layoutDirection="ltr"
    android:orientation="horizontal"
   
    >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:orientation="vertical">
       <TextView
           android:text="ksdalkdsjljsdASD"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:id="@+id/txtadvtitle"
           android:layout_gravity="right"
           android:layout_marginBottom="10dp"
           android:gravity="right"
           style="@style/txt15" />



            <TextView
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:id="@+id/txtadvdate"
                style="@style/txt14"
                 />


    <TextView
        android:layout_gravity="right"
        android:text="dadsffaf"
        android:id="@+id/txtlocation"
        style="@style/txt14"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


        <TextView
            android:layout_gravity="left"
            android:background="@color/white"
            android:padding="2dp"
            android:id="@+id/txtadvrank"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />


    </LinearLayout>

    <ImageView
        android:background="@drawable/listviewimagedraw"
        android:id="@+id/imghotel"
        android:layout_margin="3dp"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:padding="3dp"
        android:scaleType="fitXY"
        android:layout_gravity="center"
        />
</LinearLayout>

in main activity i have one framelayout. then i replace it with list fragment and in adapter i create every custom row. i checked all paddins. but there is not any thing. also i set listview style in styles but no use

1

There are 1 best solutions below

0
sara s On

thanks Keyur Nimavat fro your comment. exactly your right. when i check my design code i found padding.