0
Hello, I need to change the size of a ImageView
through the java class. And I don’t really know the command.
Follows my code
xml
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageViewVermelho"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
java class.
iv_vermelho = (ImageView) findViewById(R.id.imageViewVermelho);
I need to set the image size here
ex: if you were to do it in xml it would be like this
android:layout_width="104dp"
android:layout_height="104dp"
Friend that someoneValue; and otherValue; what is the measure I need to put in dp because when I put iv_red.getLayoutParams(). width = someValue; everything is uncoupled depending on the device resolution
– Kleber Souza
@Klebersouza this value is given in pixel. You can get the equivalent value in dp with:
pixelsValue / getResources().getDisplayMetrics().density;
– Dener