I've been following [this] answer to try to correct the heights of some image buttons in a scroll view, since I can't use linear layout weights. This is the code I've come up with:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_plant_list);
final ImageButton buttonPlant1= (ImageView) findViewById(R.id.buttonPlant1);
final ScrollView scrollViewPlant = (ScrollView) findViewById(R.id.scrollViewPlant);
scrollViewPlant.post(new Runnable() {
@Override
public void run() {
int scrollPlantHeight = scrollViewPlant.getHeight();
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, scrollPlantHeight / 3.69);
buttonPlant1.setLayoutParams(layoutParams);
}
});
}
I keep getting an alert in my code telling me that I need to import a class before the "LayoutParams.MATCH_PARENT."
When I import a class (I'm not even sure which one to import, but all I've tried is LinearLayout.LayoutParams), I get another alert telling me that it "Cannot resolve constructor 'LayoutParams(int, double)'" at the LayoutParams.MATCH_PARENT.
What class should I import? If any? Or is there something else I'm missing?