2013-10-03 2 views
5

필자는 일정한 한계 이상으로 늘어나지 않는 수직 선형 레이아웃을 가지고 있습니다. LinearLayout의 최대 높이가 있습니까?

이 더 작물 세트 레이아웃 인 이미지 뷰 http://tinypic.com/r/20nm6s/5

에서 centerCrop와 레이아웃이다 (그래서 전체 폭 거대한이어야한다) http://tinypic.com/r/vzk7kw/5

그래서 내 생각이됩니다 내 레이아웃에서 보지 못하는 암시 적 최대 높이가 있지만 어디에서 볼 수 없는지, 내 오류를 발견 할 수 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      > 
    <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:background="@drawable/dropshadow" 
      > 
     <TextView 
       android:id="@+id/heading" 
       android:layout_gravity="center" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="5dp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       /> 
     <ImageView 
      android:id="@+id/featuredimage" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:maxHeight="1000dp" 
      android:scaleType="centerCrop" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="10dp" 
      /> 
    </LinearLayout> 
</RelativeLayout> 
+0

게시 된 코드에서 LinearLayout을 사용하는 것은 아닙니다. 상대 레이아웃을 사용하여이 작업을 수행 할 수 있습니다. – dcanh121

+0

이미지의 실제 픽셀 크기는 얼마입니까? 이미지를로드하고 설정하는 코드를 게시 할 수 있습니까? –

+0

'maxHeight'를'ScrollView'에 제공하는 해결책을 찾았습니다. 이 솔루션은 모든 유형의보기에도 사용할 수 있습니다. http://chintanrathod.com/maxheightscrollview-in-android-using-android-studio/ –

답변

2

레이아웃의 "암시 적"최대 높이는 부모의 높이입니다. 두 레이아웃 모두에서 wrap_content을 사용하고 있기 때문에 부모가 이면 실제로 화면 영역에서 사용중인 다른 뷰 (예 : TextView)를 뺀 것입니다. 스크롤 컨테이너 (예 : ScrollView)에 배치하지 않으면 화면 크기를 초과하지 않습니다. ImageView의 기본 scaleTypefitCenter 때문에

당신은 작물을 제거 할 때 ImageView는 "전체 폭과 거대한를"표시되지되는 이유입니다. 이 특정보기는 레이아웃의 너비가이므로 경계선을 유지하면서 이미지를 축소합니다.

+1

에서 RelarLayout에있는 LinearLayout은 낭비입니다. XMLNS 태그를 LinearLayout에 놓고 RelativeLayout을 제거합니다. – David

+1

Linear를 제거하고 Relative를 적절한 속성으로 사용할 수도 있지만 Linear가 더 간단합니다. 어느 쪽이든, 분명히 * 둘 다 필요하지 않습니다. – Geobits

관련 문제