FrameLayout의 TextView 뒤에 이미지를 넣고 싶습니다. TextLight 내부의 높이를 조정하고 이미지 크기의 영향을받지 않기 위해서는 FrameLayout이 필요합니다. 이미지는 FrameLayout에 의해 잘린 원래 크기의 텍스트 뒤에 있어야합니다.wrap_content 높이를 사용하여 FrameLayout의 이미지 뷰 자르기
이것은 내가 시도한 것입니다.
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_gravity="right|center_vertical"
android:gravity="center"
android:alpha="0.1"
android:id="@+id/img_logo"/>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="left|center_vertical"
android:id="@+id/text_long" />
</FrameLayout>
FrameLayout의 높이가 이미지 크기의 영향을 받는다는 점을 제외하면 거의 원하는 것입니다. 텍스트로만 변경해야합니다.
이것은 해결하기 까다로운 문제입니다! 내 초기 반응은 ImageView의 높이가 wrap_content이고 프레임 뷰의 크기를 TextView의 높이에 맞게 동적으로 조정하는 동안 FrameaLayout의 높이를 고정시켜야합니다. 이 솔루션은 좀 더 우아한 접근 방법입니다 (코드는 없지만, 코드를보고 싶으면 답을 얻을 수 있습니다) : http://stackoverflow.com/a/21581103/6526330 –
@ Dr.Nitpick 시도해 보았습니다. 그것은 제대로 작동하지 않았습니다. 당신이 그것을 작동하게 만들 수 있다면 기꺼이 당신의 대답을 받아 들일 것입니다. –
물론 이죠, 오늘 밤에 시험해보고 알려주세요. –