2014-01-28 82 views
0

我是Android开发新手。我从(eclipse)android模拟器测试了我的android程序,但是当我在SAMSUNG手机中运行相同的程序时,屏幕很大,从平板电脑上我的ImageView不适合他们的屏幕。Android ImageView不适合较大的屏幕

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".CompareActivity" > 

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

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/topbar" /> 

      <TabHost 
      android:id="@android:id/tabhost" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

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

       <TabWidget 
        android:id="@android:id/tabs" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="#160203" > 
       </TabWidget> 

       <FrameLayout 
        android:id="@android:id/tabcontent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 

      </LinearLayout> 

     </TabHost> 


      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="0dp" > 

       <ImageView 
        android:id="@+id/imageView2" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:adjustViewBounds="true" 
        android:src="@drawable/crdt" /> 

       <ImageButton 
        android:id="@+id/registerbutton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="38dp" 
        android:layout_marginTop="15dp" 
        android:background="@android:color/transparent" 
        android:src="@drawable/green" /> 

       <ImageView 
        android:id="@+id/imageView3" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/imageView2" 
        android:adjustViewBounds="true" 
        android:src="@drawable/savings" /> 

       <ImageButton 
        android:id="@+id/blubutton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/registerbutton" 
        android:layout_alignTop="@+id/imageView3" 
        android:layout_marginTop="18dp" 
        android:background="@android:color/transparent" 
        android:src="@drawable/blue" /> 

       <ImageView 
        android:id="@+id/imageView4" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/imageView3" 
        android:adjustViewBounds="true" 
        android:src="@drawable/pl" /> 

       <ImageButton 
        android:id="@+id/redbutton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/blubutton" 
        android:layout_alignTop="@+id/imageView4" 
        android:layout_marginTop="17dp" 
        android:background="@android:color/transparent" 
        android:src="@drawable/red" /> 

       <ImageView 
        android:id="@+id/imageView5" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/imageView4" 
        android:adjustViewBounds="true" 
        android:src="@drawable/homlons" /> 

       <ImageView 
        android:id="@+id/imageView6" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/imageView5" 
        android:adjustViewBounds="true" 
        android:src="@drawable/fd" /> 

       <ImageButton 
        android:id="@+id/orbutton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/redbutton" 
        android:layout_alignTop="@+id/imageView5" 
        android:layout_marginTop="26dp" 
        android:background="@android:color/transparent" 
        android:src="@drawable/orange" /> 

       <ImageButton 
        android:id="@+id/pubutton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/orbutton" 
        android:layout_alignTop="@+id/imageView6" 
        android:layout_marginTop="18dp" 
        android:background="@android:color/transparent" 
        android:src="@drawable/purple" /> 

      </RelativeLayout> 

    </LinearLayout> 

</FrameLayout> 

+0

将android:scaleType =“fitXY”设置为ImageView。 –

+0

哪个imageview不适合屏幕? –

+0

@Amrola都可以请ImageViews – Akunar

回答

0

采用Android:背景= “@绘制/储蓄”

0

你可以改变你的ImageView XML作为如下:

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:scaleType="fitXY" 
android:src="@drawable/crdt" /> 

或通过代码进行更改:

imageView.setScaleType(ScaleType.FIT_XY); 
1

布局设置为wrap content,这将在较大的屏幕上留出空白区域。通知布局,使其占用所有空间。

 <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/crdt" /> 

     <ImageButton 
      android:id="@+id/greenbutton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="38dp" 
      android:layout_marginTop="15dp" 
      android:background="@android:color/transparent" 
      android:src="@drawable/green" /> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/imageView2" 
      android:adjustViewBounds="true" 
      android:alignParentBottom="true" 
      android:src="@drawable/savings" /> 


    </RelativeLayout>