【问题标题】:Android PercentRelativeLayout width and height should be specifiedAndroid PercentRelativeLayout 宽度和高度应该指定
【发布时间】:2016-08-25 08:41:49
【问题描述】:

我正在尝试使用android.support.percent.PercentRelativeLayout

<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 Studio 给我错误:

"layout_height should be specified
"layout_width should be specified"

Project is building now, but studio shows errors and do not suggest autocompletion when I start typing "percent..."

我做错了什么?

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

【问题讨论】:

  • 0dp 设为"layout_height"layout_widht....

标签: android android-percentrelativelayout android-percent-library


【解决方案1】:

问题在这里得到了回答:PercentRelativeLayout - layout_width missing warning

基本上; PercentRelativeLayout 会忽略宽度和高度,但您需要将它们设置为 0dp,因为 Android Studio 期望它们在此处。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-19
    • 1970-01-01
    • 2014-09-05
    • 2010-11-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-13
    • 1970-01-01
    相关资源
    最近更新 更多