2012-05-22 9 views
6

나는 Android 프로젝트를 진행 중입니다. ImageView ID iv1 및 iv2가 전체 화면으로 표시되지 않는 이유는 무엇입니까? 나는 아래로 여기 내 XML을 배치했습니다 내가있는 LinearLayout에 ImageViews을 배치하는 경우ImageView가 전체 화면으로 표시되지 않는 이유는 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/layout1" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:paddingBottom="10px" 
       android:paddingLeft="10px" 
> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    > 
     <ImageView 
      android:id="@+id/iv1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:visibility="invisible" 
     /> 

     <ImageView 
      android:id="@+id/iv2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:visibility="invisible" 
     /> 

      <ImageButton 
      android:id="@+id/menu_btn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_toRightOf="@+id/BunyiIng" 
      android:src="@drawable/menu_btn" 
      android:background="@null" 
     /> 

     <ImageView 
      android:id="@+id/image_logo" 
      android:src="@drawable/logo_vehicle" 
       android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      android:layout_marginTop="5px" 
     /> 

    </RelativeLayout> 
</LinearLayout> 

, 그것은 RelativeLayout의 차단.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/layout1" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:paddingBottom="10px" 
       android:paddingLeft="10px" 
> 
    <ImageView 
      android:id="@+id/iv1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:visibility="invisible" 
    /> 

    <ImageView 
     android:id="@+id/iv2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:visibility="invisible" 
    /> 

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

그러나 이미지 뷰는 RelativeLayout의 아래에 배치되지만, 내부의 LinearLayout 상기 이미지 뷰 이미지를 표시하지 않는 경우.

</RelativeLayout> 

    <ImageView 
      android:id="@+id/iv1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:visibility="invisible" 
    /> 

    <ImageView 
      android:id="@+id/iv2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:visibility="invisible" 
    /> 
</LinearLayout> 

어떻게 해결할 수 있습니까? 이미지를 전체 화면으로 보여주는 ImageView를 원합니다.

+0

한 번 시도해보십시오. - android : scaleType = fitXY' – Praveenkumar

답변

24
  1. 당신은 선형 레이아웃 패딩이있다.
  2. 이미지보기에 내용이 없으므로 내용을 볼 수 없습니다.
  3. 이미지보기를 보이지 않도록 설정 했으므로 내용을 볼 수 없습니다.
  4. 가로 세로 비율에 신경 쓰지 않는다면 android : adjustViewBounds = "false"android : scaleType = "fitXY"를 사용하십시오.
+2

대답 4가 작동합니다! 너는 내 생을 구했다. 감사!! – user1008497

2

를 사용하여 이미지 뷰에 대해이 속성 :

android:scaleType="fitXY" 
0

ImageView의 높이와 너비를 모두 "fill_parent"로 설정했기 때문에 두 이미지를 전체 화면으로 확대 할 수 있습니다. 나중에 자리에 앉아서 나중에 사용하지 않으려면

android:background="@drawable/your_drawable_here" 

을 선형 및 상대 레이아웃 모두에 추가하십시오. 그것은 레이아웃의 배경에 이미지를 추가하고, 전체 레이아웃에 맞게 크기를 조정하며, 실수하지 않으면 리소스를 절약합니다.

관련 문제