2012-09-11 5 views
0

상위 뷰의 크기와 상관없이 동일한 크기 조정을위한 로고를 얻으려고합니다. 현재 로고는 수직으로 축소되지만 수평으로는 로고가 흐리게 표시됩니다. 나는 x와 y를 동일하게 스케일링하여 모양이 뭉개지거나 펴지지 않은 형태로 유지하도록하고 싶습니다.이미지의 X와 Y를 Android의 ImageView에서 동일하게 스케일하는 방법은 무엇입니까?

다양한 scaleTypes를 시도했지만 지금까지는 도움이되지 않았습니다. 버튼

XML 코드 :

<ImageView 
       android:id="@+id/logo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@id/title" 
       android:background="@android:color/transparent" 
       android:src="@android:color/transparent" /> 

FULL XML 코드 (CONTEXT를 줄) :

이미지 디스플레이는 두 가지 요인에 의해 결정됩니다
<RelativeLayout 
      android:id="@+id/menu" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="30" 
      android:background="@android:color/transparent" 
      android:baselineAligned="false" > 

      <TextView 
       android:id="@+id/title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:gravity="right|bottom" 
       android:shadowColor="@android:color/transparent" 
       android:text="THE BLIND GOAT" 
       android:textColor="@android:color/transparent" 
       android:textSize="24dp" 
       android:textStyle="bold|italic" 
       android:typeface="sans" /> 

      <Button 
       android:id="@+id/help" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/title" 
       android:background="@android:color/transparent" 
       android:clickable="false" 
       android:paddingBottom="0dp" 
       android:paddingLeft="2dp" 
       android:paddingRight="2dp" 
       android:paddingTop="0dp" 
       android:text="HELP" 
       android:textColor="@android:color/transparent" 
       android:textSize="9dp" 
       android:textStyle="bold" 
       android:typeface="monospace" /> 

      <Button 
       android:id="@+id/settings" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@id/help" 
       android:layout_below="@id/title" 
       android:background="@android:color/transparent" 
       android:clickable="false" 
       android:paddingBottom="0dp" 
       android:paddingLeft="2dp" 
       android:paddingRight="2dp" 
       android:paddingTop="0dp" 
       android:text="SETTINGS" 
       android:textColor="@android:color/transparent" 
       android:textSize="9dp" 
       android:textStyle="bold" 
       android:typeface="monospace" /> 

      <Button 
       android:id="@+id/logout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@id/settings" 
       android:layout_below="@id/title" 
       android:background="@android:color/transparent" 
       android:clickable="false" 
       android:paddingBottom="0dp" 
       android:paddingLeft="2dp" 
       android:paddingRight="2dp" 
       android:paddingTop="0dp" 
       android:text="LOGOUT" 
       android:textColor="@android:color/transparent" 
       android:textSize="9dp" 
       android:textStyle="bold" 
       android:typeface="monospace" /> 

      <Button 
       android:id="@+id/profile" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/settings" 
       android:background="@android:color/transparent" 
       android:clickable="false" 
       android:textColor="@android:color/transparent" 
       android:textSize="15dp" 
       android:textStyle="bold" 
       android:typeface="serif" /> 

      <ImageView 
       android:id="@+id/logo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@id/title" 
       android:background="@android:color/transparent" 
       android:src="@android:color/transparent" 
       android:scaleType="centerCrop" /> 
     </RelativeLayout> 
+0

시도하십시오 android : scaleType = "centerInside" –

+0

그래, 그게 많은 스케일 타입 중 하나입니다. 감사. – jrquick

+0

오해해서 죄송합니다. 나는 당신의 코멘트를 보지 못했고 아마 우리는 같은 시간에 썼을 것입니다. 답변을 삭제했습니다. 좋은 날 –

답변

0

:

당신의 이미지 뷰의 크기 (이것을 이미지를 그릴 수있는 프레임 또는 캔버스와 위치라고 생각할 수 있습니다. ImageView이 작 으면 이미지가 해당 공간을 채울 수 있습니다.

scaleType이며, here입니다. "center"를 사용하는 scaleType 속성을 통해 ImageView을 말하면 이미지 네이티브 크기의 가운데에서 그릴 것입니다. scaleType "fit_center"를 사용하면 이미지가 올바른 비율로 ImageView 내부에 맞도록 조정됩니다 (늘어나거나 찌그러지지 않음).

희망 하시겠습니까?

관련 문제