Answer the question
In order to leave comments, you need to log in
How to arrange images in three rows in Android Studio?
There are n-th number of square pictures of the same size. It is necessary to place them in three rows so that they occupy (almost) the entire width, with the exception of indents and spacing, which should be the same both vertically and horizontally. Simply put, you need to make something like a gallery, only with small indents. How to do it? Tried through GridView, but there you need to adjust the size. I set it up for Nexus 5, but everything has already gone to Nexus S, so it's not an option.
Answer the question
In order to leave comments, you need to log in
GridView is just for this.
layout code
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/gridView"
android:numColumns="3"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth" />
<GridViewItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:scaleType="centerCrop"/>
public class GridViewItem extends ImageView{
public GridViewItem(Context context) {
super(context);
}
public GridViewItem(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GridViewItem(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question