Ich möchte alle Bilder von Benutzern in einer Gridview in einer meiner Aktivitäten angezeigt werden. Dies sind meine Codes und ich habe das Ergebnis auf dem Bild unten. Ich habe die Breite und Höhe jedes der Bilder in der Gridview (90dp, 90dp) angegeben, aber es folgt nicht. Sie werden als hochgeladene Größe (Querformat/Hochformat) ausgefüllt. Auch nach dem Einstellen der Höhe der Gitteransicht auf wrap_content bleibt die Höhe wie das Bild (ca. 200dp können b). Wie löse ich das? Wo habe ich falsch gemacht?Benötigen Sie alle Bilder der gleichen Größe in gridview android
Modell jedes Bild:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
app:srcCompat="@drawable/post2"
android:id="@+id/imageView2"
android:scaleType="centerCrop"
android:layout_margin="0dp"/>
</RelativeLayout>
Mein Gridview in einer anderen Aktivität:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_competition_user"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.golstars.www.glostars.competitionUser"
tools:showIn="@layout/activity_competition_user">
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
android:numColumns="3"
android:verticalSpacing="8dp"
android:stretchMode="columnWidth"
android:horizontalSpacing="8dp"
android:id="@+id/competitionusergrid"
/>
</ScrollView>
Mein Adapter:
MyUser mUser = MyUser.getmUser();
mUser.setContext(this);
Picasso.with(this).load(mUser.getProfilePicURL()).into(profileFAB);
targetList = new ArrayList<>();
targetAdapter = new GridAdapter(getApplicationContext(), targetList);
competitionusergrid.setAdapter(targetAdapter);
String target = "";
target = this.getIntent().getStringExtra("LOAD_TARGET");
System.out.println(target);
if(target.equals("COMPETITION")){
//if we have competition pics
if(targetList.isEmpty()){
ArrayList<String> aux = this.getIntent().getStringArrayListExtra("COMPETITION_PICS");
System.out.println("target list - " + aux);
for(int i = 0; i < aux.size(); i++){
targetList.add(aux.get(i));
targetAdapter.notifyDataSetChanged();
}
}
Wie es aussieht: UI
Vielen Dank Mann! Genau so will ich meine Sicht. –