2013-10-22 25 views
0

我創建了小的,正常的,大的和xl的佈局,當我運行代碼時,我做了 這是兩個都是正常屏幕尺寸時的結果。 如果我解決了其中一個得到了混亂,反之亦然。他們是解決這個問題的另一種方式,或者如何解決這個問題Android和支持Multiscreen的顯示圖像問題

HTC一個V- HTC one V

三星S3 Samsung 3

用於正常佈局的代碼

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/background1" 
    android:gravity="fill_vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/seekBar1" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/pumpkin" /> 

    <ImageButton 
     android:id="@+id/imageButton2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="500dp" 
     android:layout_marginTop="150dp" 
     android:background="@null" 
     android:src="@drawable/righteyeoff" /> 

    <SeekBar 
     android:id="@+id/seekBar1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/imageView1" 
     android:layout_alignParentBottom="true" 
     android:thumb="@drawable/skull" /> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="350dp" 
     android:layout_marginTop="150dp" 
     android:background="@null" 
     android:src="@drawable/lefteyeoff" /> 

</RelativeLayout> 

回答

0

您也可以使用框架/線性佈局。儘管如此,我仍然在使用dp,但數字越來越小,這就減少了你所看到的巨大差異。 我希望你仍然有這個想法,我沒有你的圖像使用如此剛剛使用的顏色。在這個例子中,你應該使用wrap_content而不是設置的寬度/高度。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:padding="20dp"> 
    <LinearLayout android:id="@+id/pumpkin" android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" android:gravity="center" android:background="@android:color/black"> 
     <ImageView android:id="@+id/leftEye" android:orientation="horizontal" android:layout_width="20dp" android:layout_height="20dp" android:layout_marginBottom="30dp" android:layout_marginRight="20dp" android:src="@android:color/holo_orange_dark" /> 
     <ImageView android:id="@+id/rightEye" android:orientation="horizontal" android:layout_width="20dp" android:layout_height="20dp" android:layout_marginBottom="30dp" android:layout_marginLeft="20dp" android:src="@android:color/holo_orange_dark" /> 
    </LinearLayout> 
    <SeekBar android:id="@+id/seekBar1" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="wrap_content" /> 
</FrameLayout> 
0

我已經發現,這是很困難的,在每個的頂部放置的物體/圖像其他使用Android。

我會把事情放在絕對中心。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

對於圖像我會使用

<ImageView 
    android:id="@+id/main_pic" 
    android:layout_width="xxdip or wrap_content " 
    android:layout_height="xxdip or wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true"> 

,並把一些在他人之上。也許眼睛(仍然在相對佈局)在鼻子上方的線性佈局。

祝你好運!

+0

您不能定義一個空layout_width /身高的形象圖,這是非法的 – JoxTraex

+0

我沒有寫這直接複製。 user1975060可以用他或她想要的任何傾角或填充來填充它 – heLL0