大家好,我是Stack和Android的新手。我遇到了重量问题。我不确定我错过了什么,因为我尝试了多种不同的方法,但似乎都没有用,或者我错过了一些东西。任何帮助将不胜感激,下面的代码
GridLayout poster_grid = findViewById(R.id.poster_grid);
for (int i = 0; i < final_image_url.size(); i++) {
String nameCut = final_image_url.get(i);
final String GAME_ID = gameId.get(i);
ImageButton posters = new ImageButton(this);
****LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
GridLayout.LayoutParams.WRAP_CONTENT,
GridLayout.LayoutParams.MATCH_PARENT,
2);****
params.setMargins(10,10,10,10);
posters.setLayoutParams(params);
posters.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent info_activity = new Intent(Poster_Activity.this, Info_Activity.class);
info_activity.putExtra("game_id", GAME_ID);
startActivity(info_activity);
}
});
Picasso.get()
.load("http:" + nameCut)
//.resize(430, 430)
.into(posters);
poster_grid.addView(posters);
}