1

안드로이드에서 다음 스크린 샷을 얻으려고합니다.안드로이드에서 다른 이미지 안에 이미지 삽입하기

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:background="@drawable/marker" 
android:orientation="horizontal" > 

<com.ylg.RoundImageView 
     android:id="@+id/profilePhoto" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:gravity="center_horizontal" 
     android:src="@drawable/profilepic" /> 

하지만 I :

https://github.com/vinc3m1/RoundedImageView

그래서 나는 다음과 같은 코드를 시도 :

enter image description here

여기에서 라운드 이미지 라이브러리가 원형 이미지를 얻으려면 오류가 발생했습니다. : 나는 아래 한 :

enter image description here

여기에서 잘못 될 수

NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first. 

Exception raised during rendering: Index: 0, Size: 0 

내 마커 이미지 9 패치가 필요합니다. 레이아웃 xml에서 abouve 스크린 샷을 얻으려면 어떻게해야합니까?

답변

2

정확히 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:orientation="vertical" 
    > 

    <RelativeLayout 
     android:layout_width="130dip" 
     android:layout_height="130dip" 
     android:background="@drawable/bg" > 

     <com.example.mmlooloo.RoundedImageView 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/imageView1" 
      android:layout_width="90dip" 
      android:layout_height="90dip" 
      android:layout_centerHorizontal="true" 
      android:layout_marginBottom="15dip" 
      android:layout_marginTop="10dip" 
      android:scaleType="centerCrop" 
      android:src="@drawable/profile" 
      app:border_color="#0000FF" 
      app:border_width="2dip" 
      app:corner_radius="80dip" 
      app:oval="true" /> 
    </RelativeLayout> 

</LinearLayout> 

과 :

<resources> 

    <!-- Default screen margins, per the Android Design guidelines. --> 
    <dimen name="activity_horizontal_margin">16dp</dimen> 
    <dimen name="activity_vertical_margin">16dp</dimen> 

</resources> 

결과 :

enter image description here

+0

고마워요. 이것은 나를 위해 문제를 해결했다. 나는 그림을 적절하게 맞추기 위해 9 가지 경로 그림으로 몇 가지를 변경했다. 모든 것이 잘되어 가고 있습니다 .. – TheDevMan

3

FrameLayout을 사용하실 수 없습니까?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.testproject.MainActivity" > 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/bg" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/overlay" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/ic_launcher"/> 

</FrameLayout> 

나는 @drawable/bg로 국경 이미지를 사용하고 나는이 출력을 얻고있다 : 귀하의 경우

enter image description here

, 사용자의 이미지 테두리 이미지보다 작은 것, 즉 맞아야하므로.

희망이 도움이됩니다.

+0

다음과 같이 표시됩니다. http://img42.com/SsRk8 – TheDevMan

+0

@TheDevMan layout.xml을 표시 할 수 있습니까? –

+0

수정 된 답변 확인. 나는 내가 얻은 것을 추가했다 @DheDevMan –

0

ImageView의 배경을 배경 이미지가 들어있는 drawable (xml) 리소스로 설정하고 ImageView src를 원하는 그림으로 설정해보십시오. 이렇게하면 문제가 해결됩니다.

편집

하면이 코드 'BB'는 backgournd 흰색 이미지와 SRC는 실제 이미지 문신이 그 위에 표시됩니다 포함

<ImageView 
     android:id="@+id/img_chatUserImg" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:background="@drawable/bb" 
     android:paddingBottom="40.0dip" 
     android:paddingTop="10.0dip" 
     android:paddingRight="10.0dip" 
     android:paddingLeft="10.0dip" 
     android:src="@drawable/ic_smiley"/> 

을보십시오.

enter image description here

나는 그에 따라 내 패딩을 조정했다.이미지 크기가 다른 경우 다른 LinearLayout에 이미지 뷰를 래핑 한 다음 배경 및 패딩을 설정하고 이미지 뷰를 내부에 배치하고 크기를 조정하여 항상 흰색 테두리 안에 유지되도록합니다.

+0

예를 들어 주시겠습니까? – TheDevMan

+0

@TheDevMan 나는 대답을 편집했습니다. 그것을 확인해주세요. – Panther

+0

@ Panther : 여기에서 내 프로필 사진을 반올림하고 RoundImageView 라이브러리를 호출하려고합니다. 배경을 사용하면 필요한 것을 성취 할 수 없습니다. – TheDevMan