2016-11-14 1 views
1

이미지가있는 오른쪽 상단 구석에 삼각형 모양이 필요합니다. 삼각형 모양은 부모 레이아웃에 따라 동적이어야합니다.이미지 안쪽에 안드로이드 안쪽에 삼각형이 있습니다

현재이 모양입니다.

enter image description here

I 게시하고 상기 이미지 개까지 생성 수로 보았다.

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


     <RelativeLayout 
      android:layout_width="200dp" 
      android:layout_height="200dp" 
      android:background="@drawable/triangle_shape" 
      android:gravity="right" 
      android:layout_gravity="right" 
      android:layout_alignParentRight="true" 
      > 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@mipmap/more_hdpi" 
       android:layout_centerVertical="true" 
       android:layout_centerHorizontal="false" 
       /> 

    </RelativeLayout> 

</RelativeLayout> 

triangle_shape.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item> 
     <rotate 
      android:fromDegrees="-45" 
      android:toDegrees="45" 
      android:pivotX="0%" 
       android:pivotY="-45%" > 
      <shape 
       android:shape="rectangle" > 
       <stroke android:color="@color/yellow" android:width="10dp"/> 
       <solid 
        android:color="@color/yellow" /> 
      </shape> 
     </rotate> 
    </item> 
    </layer-list> 

, 당신이 난 모양의 하단에 수정 폭과 이미지의 모습을 보는 바와 같이 내가 좋아하는 모양의 중앙에 필요 :

이것이 내가 원하는 것입니다.

enter image description here

내가 그것을 높이와 폭과 같은 것처럼 보이는데보기를 하사하다 안드로이드 스튜디오에서 보면 모양의 두 배입니다. 그 이유는 모양이 실제로 직사각형이며 회전하기 때문입니다.

현재 Android 스튜디오 미리보기에서 찾습니다.

enter image description here

나는 this처럼 많은 게시물에 보이지만 어떤에서 솔루션을하지 않았다. 어떤 도움이라도 대단히 감사하겠습니다.

+0

그래서 실제로 어떤 문제가 있습니까? – pskink

+0

@pskink 모양의 중심에 이미지가 필요하고 모양의 너비가 고정되어서는 안됩니다. 현재 레이아웃의 크기가 거의 두 배임을 알 수 있습니다. 내 노력을 게시했습니다 – ketan

+0

그래서 너는 어떤 너비를 원하니? "너 내가 원하는거야." 이미지 너비가 이미지 너비보다 2 배 크다. 맞습니까? – pskink

답변

0

나는 체크하지 않았지만 삼각형과 이미지를 중력 중심의 특정 상대 레이아웃으로 배치하여 시도 할 수 있습니다. 이게 도움이 될지 알려 줘.

+0

나는 그걸 해냈고 다음과 같이 보였다. https://i.stack.imgur.com/zwUd6.png – ketan

관련 문제