Set ImageView's max width as a percent of its parent's width

非 Y 不嫁゛ 提交于 2019-11-27 08:53:44
Emmanuel

This can't be done in the XML. You would have to specify the size in the code. I would do that in the onCreate() of the activity:

import android.widget.LinearLayout.LayoutParams;
...
obj.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                                     LayoutParams.WRAP_CONTENT,
                                     0.25f));

This means use 100% of the parent's height but 25% of the parent's width.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!