ernesto logo
Torna al Magazine
Installazione dell'asfalto: come trovare posatori
consigli
Installazione dell'asfalto: come trovare posatori

Come Trovare Posatori per l'Installazione dell'Asfalto

Come Trovare Personale per l'Installazione dell'Asfalto.

Stai cercando di uniformare l'altezza delle righe nel tuo ListView Android? Scopri come implementare un layout XML e un adapter personalizzato per garantire che ogni riga abbia la stessa altezza. Segui i nostri consigli per migliorare l'aspetto della tua app e offrire un'esperienza utente ottimale, ottimizzando il design della tua interfaccia.

Trova professionisti vicino a te

Trova professionisti
Q: How to make a listview with the same row height? In my Android app I am trying to make a ListView which has the same row height. For this I have created a xml layout for the row, which I am using in the adapter. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dip" > <TextView android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:textColor="@android:color/black" android:textSize="17dip" /> <TextView android:id="@+id/comment" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="2dip" android:textColor="@android:color/black" android:textSize="14dip" /> <TextView android:id="@+id/date" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="2dip" android:textColor="@android:color/black" android:textSize="14dip" /> </LinearLayout> This is my adapter: public class MyArrayAdapter extends ArrayAdapter<Sample> { private final Context context; private final Sample[] samples; public MyArrayAdapter(Context context, Sample[] samples) { super(context, R.layout.row_layout, samples); this.context = context; this.samples = samples; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.row_layout, parent, false); TextView name = (TextView) rowView.findViewById(R.id.name); TextView comment = (TextView) rowView.findViewById(R.id.comment); TextView date = (TextView) rowView.findViewById(R.id.date); Sample sample = samples[position]; name.setText(sample.getName()); comment.setText(sample.getComment()); date.setText(sample.getDate()); return rowView; } } But the problem is that the row height is not same for all rows. How can I make the ListView with the same row height? A: ListView will adjust the row height to fit the content of the row. What you can do is set the minHeight attribute of the RowView: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dip" android:minHeight="50dp" > This will set the minimum row height to 50dp.
Ultimo aggiornamento
30 Mar 2025
Luca De Santis
Luca De Santis

Autore specializzato nel raccontare come funziona il mondo dei servizi locali e come trovare i professionisti migliori.