0

i am developing an android application

i design my xml so it is

enter image description here

However, when i run the application on emulator, i got this result

enter image description here

notice please the circle red. why this different between the two?

my english is bad, if u didn't understood me, please say to me

this is the xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/iv_logo"
                android:layout_width="150sp"
                android:layout_height="150sp"
                android:background="@drawable/roma_logo" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/iv_logo"
                android:paddingLeft="10sp"
                android:paddingTop="10sp"
                android:text="@string/action_settings"
                android:textColor="#000000"
                android:textSize="20sp" />

            <Button
                android:id="@+id/b_subscribe"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/iv_logo"
                android:layout_alignParentRight="true"
                android:text="@string/action_settings" />
        </RelativeLayout>

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:src="@drawable/boarder" />

        <HorizontalScrollView
            android:id="@+id/hsv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            android:measureAllChildren="false"
            android:scrollbars="none" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <ImageView
                    android:layout_width="200sp"
                    android:layout_height="289sp"
                    android:paddingRight="@dimen/activity_horizontal_margin"
                    android:src="@drawable/roma1" />

                <ImageView
                    android:layout_width="200sp"
                    android:layout_height="289sp"
                    android:paddingRight="@dimen/activity_horizontal_margin"
                    android:src="@drawable/roma2" />

                <ImageView
                    android:layout_width="200sp"
                    android:layout_height="289sp"
                    android:paddingRight="@dimen/activity_horizontal_margin"
                    android:src="@drawable/roma3" />
            </LinearLayout>
        </HorizontalScrollView>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/border_thin"
                android:paddingBottom="@dimen/activity_vertical_margin"
                android:src="@drawable/boarder_thin" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center|left"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:text="@string/date_of_establishment"
                android:textColor="#da1337"
                android:textSize="20sp"
                android:textStyle="italic" />

            <TextView
                android:id="@+id/tv_date_of_establishment"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:text="1999"
                android:textColor="#000100"
                android:textSize="15sp" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/border_thin"
                android:paddingTop="@dimen/activity_vertical_margin"
                android:src="@drawable/boarder_thin" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

the wrong happended in the imageview witch have drawable called boarder and boarder_thin

user3110137
  • 147
  • 1
  • 10
  • I am not sure but use dp instead of sp for width, height and padding. And give a try. – Tabrej Khan Dec 28 '13 at 14:17
  • px is one pixel. sp is scale-independent pixels. dip is Density-independent pixels. You would use sp for font sizes dip for everything else. dip==dp – Tabrej Khan Dec 28 '13 at 14:18
  • @TabrejKhan where should i use dp? what is the matter with dp in the my problem please? – user3110137 Dec 28 '13 at 14:23
  • Refer [this](http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android) and [this](http://blog.edwinevans.me/?p=131) for details. – Tabrej Khan Dec 28 '13 at 14:26
  • @TabrejKhan my friend, i dont have any padding in the imagviews. however, i tired your solution, but still the same problem – user3110137 Dec 28 '13 at 14:37

1 Answers1

1

Perhaps the image is smaller than the display width.

Add android:scaleType="fitXY" to ImageView to scale it

The same effect can be achieved by changing android:src="@drawable/boarder" to android:background="@drawable/boarder"

Background drawables always fit the view.

ramaral
  • 6,149
  • 4
  • 34
  • 57