2014-12-14 2 views
1

세로 방향이있는 LinearLayout 안에 일부 TextViews 및 ImageView가 포함 된 화면이 있습니다. 모든 것을 화면에 정확하게 맞추고 싶습니다 (크기가 무엇이든 관계없이). ImageView는이를 수용하기 위해 자체 조정됩니다.전체 레이아웃 채우기 화면을 만들기 위해 ImageView 크기 조정

이 질문에 대한 답변 (this 포함)을 보았지만 실제로 내 요구 사항에 맞는 답변을 찾지 못했습니다. 내가 안에있는 ScrollView 전체의 LinearLayout을두고있다 아주 "꽤"가 아닌 솔루션을 사용하고, 그 된 onMeasure 방법에의 높이 사이의 델타를 계산하는 사용자 정의 이미지 뷰를 사용했습니다 지금까지

화면 높이까지 스크롤하십시오. 전자가 후자보다 크면 ImageView의 측정 된 높이에서 델타를 뺍니다.

이 솔루션은 완벽하지 않으며 더 좋은 것이 있는지 정말로 알고 싶습니다. 확실 해요.

감사합니다.

편집 : 여기에 레이아웃 XML을

<com.xxx.widgets.LockableScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:custom="http://schemas.android.com/apk/res/com.venews" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    custom:scrollable="false" 
    android:fillViewport="true"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="@dimen/login_horizontal_margin" 
    android:paddingRight="@dimen/login_horizontal_margin" 
    android:orientation="vertical"> 

    <com.xxx.widgets.ResizableToFitScreenImageView android:id="@+id/login_logo_image" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginTop="@dimen/login_logo_margin" 
     android:layout_marginBottom="@dimen/login_logo_margin" 
     android:src="@drawable/ic_logo_and_name"/> 

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

     <TextView android:id="@+id/login_username" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true"/> 

     <TextView android:id="@+id/login_password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/login_username"/> 

     (...Other stuff...) 

    </RelativeLayout> 

</LinearLayout> 

</com.xxx.widgets.LockableScrollView> 

EDIT2입니다 : 여기에 내가 일을 명확하게 희망 스케치입니다. enter image description here

이 솔루션은 화면 크기가 다른 여러 장치를 지원해야하므로 스케치에 2 개의 다른 화면 크기가 표시됩니다.

+0

xml을 게시 할 수 있습니까? –

+0

달성하고자하는 것을 이해하기 어렵습니다. 원하는 UI 스케치를 게시 할 수 있습니까? – Egor

+0

@ warl0ck08이 (가) 내 질문을 편집했습니다. – AsafK

답변

1

ImageView에서 android:layout_height="0dp"android:layout_weight="1"을 설정하십시오. 그러면 나머지 공간을 채 웁니다 (layout_weight에 대한 자세한 내용 here).

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

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

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

</LinearLayout> 
+0

글쎄 그건 그냥 당황 스럽네요. 가끔 인스턴트 메신저를 복잡하게 만듭니다. 엄청나게 간단한 답변을 주셔서 감사합니다. – AsafK

관련 문제