1
원하는 너비 치수 만 지정하고 자동 높이를 지정하는 PercentRelativeLayout을 사용할 수 있습니까?너비 만 지정하는 PercentRelativeLayout 사용 (heigh auto)
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/earthImageView"
app:layout_widthPercent="30%"
android:src="@drawable/earth"
android:layout_alignParentRight="true"
android:adjustViewBounds="true"/>
</android.support.percent.PercentRelativeLayout >
뷰가 올바른 폭을 가지고 있지만 내가 레이아웃 경계를 확인하면 나는 높이가 MATCH_PARENT 것을 볼 수 있습니다
나는이 일을 의미합니다. 모자 android : adjustViewBounds = "true"가 작동하지 않습니다.
app : layout_widthPercent = "WRAP_CONTENT"를 추가하려고했지만 효과가 없습니다.
감사합니다.
편집 :
<ImageView
android:id="@+id/earthImageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_heightPercent="20%"
android:src="@drawable/earth"
android:adjustViewBounds="true"/>
가! 덕분에 작동하는 것 같다! – NullPointerException
btw 너비 대신 높이 비율로 시도하면 ... 같은 오류가 발생합니다. 질문에 새로운 문제를 추가했습니다. 제발 테스트 할 수 있습니까? – NullPointerException
그건 좋은 질문 @ NullPointerException, 그것도 작동하지 않는 것 같습니다. 이미지의 비율을 알고 있습니까? 그렇다면 layout_width (및 layout_height)를 제거하고 'app : layout_aspectRatio = "80 %"'예를 들어 – mVck