1

android.support.percent.PercentRelativeLayout을 사용하려고합니다.
Android % 레이아웃의 너비와 높이를 지정해야합니다.

<ScrollView 
    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:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.percent.PercentRelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white"> 

    <ImageView 
       app:layout_widthPercent="70%" 
       app:layout_aspectRatio="1000%" 
       app:layout_marginTopPercent="15%" 
       android:layout_centerHorizontal="true" 
       android:src="@drawable/logo"/> 
    </android.support.percent.PercentRelativeLayout> 
</ScrollView> 

안드로이드 스튜디오 나에게 오류를 제공합니다

"layout_height should be specified 
"layout_width should be specified" 

프로젝트는 현재 구축되어 있지만, 스튜디오 오류를 표시하고 내가 "... %가"를 입력하기 시작하면 자동 완성을하지 않는 것이 좋습니다.
내가 뭘 잘못하고 있니?

Here is 공식 사이트의 예, 왜 작동하지 않습니까?

+1

"layout_height"및 "layout_widht"에 대해 '0dp'로 지정하십시오 .... – sushildlh

답변

2

문제는 여기에 대답했다 : 기본적으로 PercentRelativeLayout - layout_width missing warning

; 너비와 높이는 PercentRelativeLayout에 의해 무시되지만, Android Studio는이 값을 여기에 있기를 기대하기 때문에 0dp로 설정해야합니다.