E
E
En1q0d2016-02-08 18:47:06
Android
En1q0d, 2016-02-08 18:47:06

What is causing the ImageView resizing error?

I want to make the width and height of the ImageView change depending on the screen resolution (0.8 * display_width and display_height * 0.8), and I found this way for this, but when the application starts, it immediately dies, how to fix it?

<code lang="java">
ImageView spaceadventure = (ImageView)  findViewById(R.id.imageView);
        float density = getApplicationContext().getResources().getDisplayMetrics().density;
        spaceadventure.setLayoutParams(new AbsListView.LayoutParams((int) (density * 1), (int) (density * 1)));
</code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lomikman, 2016-02-09
@En1q0d

try using Percent Library
inthecheesefactory.com/blog/know-percent-support-l...
www.androidauthority.com/using-the-android-percent...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question