Android百分比布局宽度和高度应该指定
问题描述:
我正在尝试使用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来自官方网站的示例,为什么它不起作用?
答
的问题是在这里找到答案:PercentRelativeLayout - layout_width missing warning
基本上; PercentRelativeLayout会忽略宽度和高度,但您需要将它们设置为0dp,因为Android Studio期望它们在此处。
使''layout_height'和''layout_widht'成为'0dp' .... – sushildlh