I recently create a listview with an array adapter and customview. here is what I do
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final Model_order m_order = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.single_item_order, parent, false);
}
...
}
and here is my single_item_order
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
>
<TextView
android:layout_gravity="center_vertical"
android:visibility="invisible"
android:textAlignment="center"
android:layout_width="0dp"
android:layout_weight="0"
android:layout_height="wrap_content"
android:id="@+id/code"
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
/>
<TextView
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
android:layout_gravity="center_vertical"
android:textAlignment="center"
android:id="@+id/name"
android:layout_width="0dp"
android:layout_weight="35"
android:layout_height="wrap_content" />
<TextView
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
android:layout_gravity="center_vertical"
android:textAlignment="center"
android:id="@+id/price"
android:layout_width="0dp"
android:layout_weight="35"
android:layout_height="wrap_content" />
<TextView
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
android:id="@+id/qty"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:textAlignment="center"
/>
<TextView
android:textAlignment="center"
android:id="@+id/total"
android:layout_width="0dp"
android:layout_weight="20"
android:layout_height="wrap_content" />
<Button
android:id="@+id/add"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:minHeight="0dp"
android:minWidth="0dp" />
<Button
android:id="@+id/min"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:minHeight="0dp"
android:minWidth="0dp" />
</LinearLayout>
and here is what I get
Now, I am trying to remove padding. here is what I try so far
- Add padding 0dp in my
single_item_order
still not working - adding
android:dividerHeight="0dp"
to my listview tag still not working - trying this answer https://stackoverflow.com/a/5309871/10298089 still no help
so how can I remove it ? or at least I can adjust the padding .
Here is my activity main which is containing my listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/bubble_outerWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:clipToPadding="false"
android:layout_marginBottom="0dp"
/>
<View
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="match_parent" />
<android.support.v7.widget.CardView
android:layout_gravity="end"
android:layout_width="0dp"
android:layout_weight="45"
android:padding="0dp"
android:layout_margin="0dp"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/side_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Order Information"
android:textSize="14sp"
android:typeface="serif" />
<ListView
android:layout_below="@id/side_title"
android:layout_marginTop="5dp"
android:id="@+id/listss"
android:layout_width="match_parent"
android:layout_height="250dp" />
<LinearLayout
android:layout_below="@id/listss"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:minHeight="0dp"
android:minWidth="0dp"
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pay"
/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>