2013-02-19 6 views
3

저는 Imageview를 이와 같이 설정하고 싶습니다.이미지 뷰 위치 설정이 이미지

(http://wemakeucc.com/4.jpg) < - 체크 이미지

난 단지 지금까지이 같은 이미지 뷰를 사용하십시오.

<ImageView 
    android:id="@+id/a_01_b" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:src="@drawable/a_01_i" /> 

그래서이 이미지와 같은 이미지 뷰를 설정할 수있는 코드를 알고 싶습니다.

어떻게해야합니까?

+0

을 설정 – Triode

+0

그래서 .. xml 안에 set top와 left 값을 위해 무엇을해야합니까? – KRJ

+0

코드로 설명해주세요. 초보자이므로 이해할 수 없습니다 – KRJ

답변

1

여기에 귀하의 요구 사항에 따라 코드입니다 :

XML 파일 : 스크린 샷

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:orientation="vertical" 
     android:paddingBottom="30dp" 
     android:paddingRight="20dp" 
     android:paddingTop="20dp" > 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/android" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:orientation="vertical" 
     android:paddingBottom="30dp" 
     android:paddingRight="120dp" 
     android:paddingTop="20dp" > 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/android" /> 
    </LinearLayout> 

</LinearLayout> 

enter image description here

지금 바로 DP 통해 UR 필요에 따라 패딩 ... 당신은 XML 내부 위쪽 및 왼쪽 값을 설정할 수 있습니다

-1

찾고있는 답변은 [LayoutParams] [1]입니다.

은 귀하의 질문에 대답하기 :

ImageView iv = (ImageView)findViewById(R.id.my_imageView); 
AbsoluteLayout.LayoutParams absParams = 
    (AbsoluteLayout.LayoutParams)iv.getLayoutParams(); 
absParams.x = myX; 
absParams.y = myY; 
iv.setLayoutParams(absParams); 

설명 : 아래의 다음과 같은 XML을 참조하여 이미지 뷰에 대한

2

를 앵커 포인트의 어떤 종류 (X/Y를 (설정하는

<?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="fill_parent" > 

    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="40dip" 
     android:layout_marginTop="60dip" // give dip value according to where you want to place first image view from top 
     android:background="@color/black" // set image according to you 
     android:id="@+id/imageviewone" /> 

    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="40dip" 
     android:layout_marginTop="60dip" // give dip value what you have given to first edit text 
     android:background="@color/black" // set image according to you 
     android:layout_below="@+id/imageviewone" 
     android:id="@+id/imageviewtwo" /> 
    </RelativeLayout> 

이게 당신에게 도움이되는지 알려주세요

관련 문제