I've been stuck on this for quite some time now. The problem is that I have a linearlayout consisting of multiple textViews and an imageView. However, the imageview has a smaller width than the textviews. I tried everything i could find, but I couldn't find it. I am able to set the image to the left or right by using gravity, but when i use fill, it just centers and keeps the small width. The only thing i can think of is that the image is downloaded in a different thread. Can the width only be set after the image is downloaded?
// Download photo
this.post_body.setPhoto(url);
// Add imageview to linear layout
this.ll.addView((View) this.post_body.photo);
LinearLayout.LayoutParams layoutParams;
layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.FILL_HORIZONTAL;
this.post_body.photo.setLayoutParams(layoutParams);
Just try to set width=0 and set weight 1 for all the textview and buttons, imageviews whatever you want.
Just try like this here 1f is weight.
layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);