Android - Remove Extra Space Of Listview Header Image
I have a listview with a header image , there is extra space top and bottom of the image . I want to remove the space from it , My layout is LinierLayout if anyone knows please
Solution 1:
This should work:
ListViewlistView= getListView();
ImageViewmListHeader=newImageView(getContext());
mListHeader.setImageResource(R.drawable.individuals_img);
mListHeader.setScaleType(ImageView.ScaleType.FIT_XY);
mListHeader.setLayoutParams(newAbsListView.LayoutParams(1400,974));
mListHeader.requestLayout();
listView.addHeaderView(mListHeader);
Solution 2:
Inflate a custom layout as your listview
header and add below imageview
to it
code:
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListViewlist= (ListView) findViewById(R.id.list);
Viewheader= getLayoutInflater().inflate(R.layout.header, list, false); //custom layout
list.addHeaderView(header, null, false);
}
try this: in your header.xml
add the header image
<ImageView
android:id="@+id/imageView"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:src="your_source"
android:layout_marginLeft="10dp"
android:layout_marginRight="0dp"
android:layout_marginStart="0dp"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:paddingBottom="0dp"
android:scaleType="fitXY" />
Post a Comment for "Android - Remove Extra Space Of Listview Header Image"