Reputation: 7117
I want to develop an app for smartphones and tablets. Now my problem is that my layout isn't scalled in the right dimensens. On a 10' tablet it looks like this:
But this here are screenshoots from a 7' tablet and from a smartphone:
I would like to set a min width and height for the ImageView and scale it up and down depending on the screen size so in each layout the ListView is visible. Which unit do I have to use for the ImageView width and height? I tried with dp, in and some more but that does not help...
Upvotes: 2
Views: 498
Reputation: 26034
Use
<ImageView
android:layout_width="@dimen/imageViewWidth"
android:layout_height="@dimen/imageVewHeight"
android:scaleType="fitXY"
/>
scaleType="fitXY" will scale your image and fit with ImageView width and height. This will solve your problem.
Edit
In your values directory, open strings.xml file, then add following lines
<dimen name="imageViewWidth">30dp</dimen>
<dimen name="imageViewHeight">30dp</dimen>
Now, open values-sw600dp directory (of not, create one) and open strings.xml file (if not, copy from other values directory).
<dimen name="imageViewWidth">100dp</dimen>
<dimen name="imageViewHeight">100dp</dimen>
Now, open values-sw720dp directory (of not, create one) and open strings.xml file (if not, copy from other values directory).
<dimen name="imageViewWidth">120dp</dimen>
<dimen name="imageViewHeight">120dp</dimen>
This will solve your problem of different sizes of ImageView for different layouts.
Still can't understand, read my answer at
Upvotes: 1