2016-08-25 179 views
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> 

Android的工作室给我的错误:现在

"layout_height should be specified 
"layout_width should be specified" 

项目正在建设,但工作室的显示错误,当我开始打字“百分比......”不建议自动完成。
我在做什么错?

Here is来自官方网站的示例,为什么它不起作用?

+1

使''layout_height'和''layout_widht'成为'0dp' .... – sushildlh

回答