-1

이미지가 레이아웃의 경계를 정의하고 다른 모든 elemets가 자신을 방향 지을 필요가 있습니다. 여기이미지가 안드로이드에서 레이아웃을 정의하게하는 방법

Screenshot

내 문제는 이미지의 끝에 도달 할 때 내가 텍스트 줄 바꿈 할 것입니다. 레이아웃 XML을 통해이 문제를 해결하는 방법을 알고 싶습니다. 아니면 코드를 통해이를 구현해야합니까?

내 현재 레이아웃은 다음과 같습니다

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@color/KHFGreen" 
     android:padding="3dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginTop="20dp" 
     android:layout_marginBottom="20dp" 
     android:layout_gravity="left|center_vertical"> 

     <ImageView 
      android:id="@+id/icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/five" 
      android:scaleType="fitCenter" 
      android:adjustViewBounds="true" /> 

     <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="20dp" 
      android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore. " 
      android:layout_gravity="left|center_vertical" 
      android:nestedScrollingEnabled="false" /> 

    </FrameLayout> 
</FrameLayout> 

많은 감사를!

+0

사용 matchparent ellipsize ="텍스트 "종료 – KOTIOS

+0

감사합니다 nswer하지만이 불행히도 아무것도 변경되지 않습니다 :/ –

+0

난 그저 UR 레이아웃을 누른 다음 r에 동일한 이미지를 사용하여 국경을 볼 수 있습니까? – KOTIOS

답변

-1

아래의 논리를 oncreate 메소드에 추가하십시오. nestedScrollingEnabled는 = "false"로하고 유 물었다 내가 가지고 노력하고 나는 안드로이드를 추가 할 수 없습니다입니다 :

enter image description here

imageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 

    @Override 
    public void onGlobalLayout() { 

     textView.getLayoutParams().width = imageView.getMeasuredWidth(); 

     if (Build.VERSION.SDK_INT >= 16) { 
      imageView.getViewTreeObserver().removeOnGlobalLayoutListener(this); 
     } else { 
      imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this); 
     } 
    } 
}); 
나는 안드로이드를 제거 할 때 nestedScrollingEnabled = "거짓"또한, "오류 : 없음 자원 식별자 속성에 대한 발견 'nestedScrollingEnabled'패키지 '안드로이드'에 : 당신은 "UR 이미지 뷰와 안드로이드에 대한

enter image description here

+0

안녕하세요. 노력해 주셔서 감사합니다.하지만 불행히도 제가 필요한 것은 아닙니다. 내 스크린 샷은 이미지보다 넓지는 않지만 이미지가 끝나는 곳을 감싸는 TextView가 필요하기 때문에 필요합니다. 어떤 아이디어? –

+0

안녕하세요, 프로그래밍 방식으로 XML에서하는 것보다 수행 할 수 있습니다. –

+0

그래, 그것을 프로그래밍 할 때 그것은 작동합니다. 도와 줘서 고마워. 나는 아직까지 Windows (Phone) 8을 개발 중이며 거기에있는 designtools에 의해 매우 버릇이있다. :) –