2017-01-24 1 views
0

방향이나 화면 크기에 관계없이이 그림을 전체 화면에 표시하는 방법에 대한 힌트를 제공해주세요.스크롤 할 수있는 relativeLayout의 배경 이미지

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 

    tools:context="com.gadgetcatch.alex.cardcelebration.MainActivity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:src="@drawable/background" /> 

    </RelativeLayout> 
</ScrollView> 

위 그림은 Nexus4와 Nexus 10에 대한 설명이 없습니다. 넥서스 10에서는 그림이 주 이미지에 있지 않아서 시작됩니다. Nexus4 Nexus10

추가 adjustViewBounds = "사실은"화면으로 넓은 화면을 수행하지만 여전히 넥서스의 하단에 빈 스트립 잎 (10) 장치를 사용해야합니다 무엇 atribute

picture with adjustView

사용 된 장치에 관계없이 그림이 전체 화면을 차지하게됩니다. 도움을 줄 수있는 사람에게 미리 감사드립니다.

답변

0

상대 화면 레이아웃이 전체 화면을 차지하지 않는 한, 이미지보기에서 일치하는 부모 속성이 있으므로 맨 아래에 흰색 줄무늬가 표시됩니다.

이 내가 할 것 인 것이다 :

  • 는 match_parent 폭과 높이, 루트 레이아웃으로 FrameLayout이를 사용합니다.
  • 이미지 뷰를 자식으로, match_parent 너비와 높이 및 android : scaleType = "centerCrop"을 추가하십시오.
  • ScrollView를 FrameLayout 하위로 추가하십시오.

따라서, 구조는 다음과 같이됩니다 : 나 이미지가 스크롤되지 않습니다이 방법을 사용하여 추가 깜빡

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

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/background" 
     android:scaleType="centerCrop" /> 

    <ScrollView 
     android:id="@+id/activity_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
     </RelativeLayout> 

    </ScrollView> 

</FrameLayout> 

, 항상 화면 전체를 커버합니다.

+0

그것이 가지고있는 문제가 해결되면 답이 좋습니다. 그것은 내가 원했던 것이 아니라 작동합니다. 감사! –

0

android:scaleType="centerCrop" android:adjustViewBounds="true"을 추가하면 이미지가 전체 화면으로 채워지지만 옆면이 잘릴 수 있습니다.

+0

이것은 내가 여기서 말하고자하는 것입니다. centerCrop 및 adjustViewBounds를 사용하면 전체 화면이 채워지지 않습니다. 이 장치를 장치로 옮길 때 맨 아래에 흰 줄이 남습니다. –

+0

android : fillViewport = "true"to ScrollView – Kiskunk

+0

아직 작동하지 않습니다. 나는 내가 보지 못하는 무언가 어리 석다는 것을 확신합니다 ... –