2016-08-25 10 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

答えて

2

質問はここに答えた:基本的にPercentRelativeLayout - layout_width missing warning

。幅と高さはPercentRelativeLayoutによって無視されますが、Androidスタジオではそれらがここに来ることを期待しているので、0dpに設定する必要があります。

関連する問題