我想在我的一個活動中顯示用戶在gridview中發佈的所有圖片。這些是我的代碼,我在下面的圖片中顯示結果。我在gridview(90dp,90dp)中指定了每個圖片的寬度和高度,但它並沒有遵循。他們被填充爲他們上傳的大小(橫向/縱向)。甚至在將gridview的高度設置爲wrap_content之後,高度仍然像圖片一樣(大約200dp或者b)。我該如何解決這個問題?我在哪裏做錯了?每張照片的需要所有在gridview中相同大小的圖片android
型號:
<?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>
我的另一個動作的GridView:
<?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>
我的適配器:
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();
}
}
如何看起來:UI
感謝很多人!這正是我想要的觀點。 –