Reputation: 2520
I create a view with an image-view at the top of the view. The images are in size 1080-800px. If I take a look on my HTC One, it is perfekt. The image width takes the whole-screen. If I take another device , which is bigger or shorter , the images are to small or to big! I put the images to the drawable-xxhdpi folder. Should I scale them with photoshop to different sizes?
You can see, the size at the left is perfekt, but how I can handle bigger devices like that one on the right side?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/layout">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Crunch"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/crunch1" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/crunch2" />
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/crunch" />
<TextView
android:id="@+id/TVTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<Button
android:id="@+id/pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="verlaufKlick"
android:text="@string/pause"
android:visibility="invisible"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0
Views: 117
Reputation: 298
Change this
android:layout_width="wrap_content"
to this
android:layout_width="match_parent"
and add
android:adjustViewBounds="true"
Upvotes: 2
Reputation: 454
put your image (with the same name) with different resolution in
drawable-hdpi, drawable-mdpi, drawable-ldpi, drawable-xhdpi, drawable-xxhdpi
so that android will choose automatically the image that corresponds to your screen resolution
Upvotes: 2