2014-07-05 1 views
1

enter image description hereAndroid : Offset ImageView in Center 약간

다음 이미지가 가운데에 있다고 가정합니다. 이렇게하려면 다음 코드를 사용합니다.

<RelativeLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="10" 
    android:orientation="vertical" > 
    <ImageView 
     android:src="@drawable/logo" 
     android:layout_centerInParent="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
</RelativeLayout> 

이것은 데드 센터 위치 지정을 위해 작동하고 있습니다. 나는 다음과 같이하고 싶다. 약간 상향 조정한다. 보시다시피 이미지가 중심선을 가로 지르는 것을 원하지 않습니다 (보이지 않는 뷰를 추가하여 이미지를 수정하는 방법을 알고 있습니다).

enter image description here

답변

2

찾을 가짜보기가 100dp 긴 만드는 가짜보기 아이디어에서 나에게 또 다른 힌트를주는 게시, 가짜보기 하단 패딩 100dp 긴 (그래서 푸시 다운 할 것) 한 후 내 의견을 정렬 가짜보기 하단에 완벽 하단.

<RelativeLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="10" 
    android:orientation="vertical" > 
    <View 
     android:id="@+id/anchor" 
     android:layout_width="wrap_content" 
     android:layout_height="100dp" 
     android:layout_centerInParent="true" 
     android:paddingBottom="100dp" /> 

    <ImageView 
     android:src="@drawable/logo" 
     android:layout_alignBottom="@id/anchor" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
</RelativeLayout> 
+0

완벽하게 작동 해 주셔서 감사합니다. 나는 앵커 뷰에서'paddingBottom'을 필요로하지 않았다. – Mike76