Android您必须提供layout_width属性

时间:2016-06-20 13:05:20

标签: android

下面的xml布局是我简单的应用程序布局,但在编译应用程序后,我收到此错误:

Unable to start activity ComponentInfo{ir.pishguy.signalpresentationproject/ir.pishguy.
signalpresentationproject.Activities.ActivityMain}: 
android.view.InflateException: 
Binary XML file line #147: Binary XML file line #147: 
You must supply a layout_width attribute.

我的所有小部件都有layout_width,但我不知道为什么会出现此错误

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical">

        <!--<android.support.v4.widget.SwipeRefreshLayout-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="65dp"
                    android:background="@color/signal_toolbar_color"
                    android:titleTextColor="#ffffff">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="horizontal">

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/signal_robot"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginLeft="10dp"
                            android:clickable="true"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-android}"
                            android:textColor="@color/quote"
                            android:textSize="25sp"/>

                        <com.joanzapata.iconify.widget.IconTextView
                            android:id="@+id/search_icon"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:gravity="center|right"
                            android:shadowColor="#22000000"
                            android:shadowDx="3"
                            android:shadowDy="3"
                            android:shadowRadius="1"
                            android:text="{fa-search}"
                            android:textColor="#ffffff"
                            android:textSize="25sp"/>

                        <com.gigamole.library.ntb.NavigationTabBar

                            android:id="@+id/navigationTabBar"
                            android:layout_width="150dp"
                            android:layout_height="30dp"
                            android:layout_gravity="center_vertical|left"
                            android:background="@drawable/bg_round_circle"
                            app:ntb_active_color="#4527A0"
                            app:ntb_animation_duration="150"
                            app:ntb_corners_radius="50dp"
                            app:ntb_inactive_color="#dddfec"
                            app:ntb_preview_colors="@array/red_wine"/>

                        <TextView
                            android:id="@+id/activity_market_robot_title"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_marginRight="10dp"
                            android:layout_weight="1"
                            android:gravity="center|right"
                            android:text="@string/app_name"
                            android:textColor="#ffffff"
                            android:textSize="18sp"/>

                    </LinearLayout>

                </android.support.v7.widget.Toolbar>
            </android.support.design.widget.AppBarLayout>
            <!-- android.support.v4.widget.NestedScrollView -->

            <android.support.v4.view.ViewPager
                android:id="@+id/vp_horizontal_ntb"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
        </LinearLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/activity_main_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:layout_margin="20dp"
            android:clickable="true"
            android:src="@drawable/ic_add_circle_outline"
            android:tint="@color/white"
            android:visibility="gone"
            app:backgroundTint="@color/signal_secondary_color"
            app:layout_behavior="ir.pishguy.signalpresentationproject.Configurations.ScrollAwareFABBehavior"/>

        <ir.pishguy.signalpresentationproject.Widgets.CircularRevealView
            android:id="@+id/market_item_reveal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"/>
    </android.support.design.widget.CoordinatorLayout>

    <com.lapism.searchview.SearchView
        android:id="@+id/searchView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</FrameLayout>

1 个答案:

答案 0 :(得分:3)

您添加了此行,使XML无效。

@xw.func
def plot_fig():
    wb = xw.Wookbook.caller()
    df = pandas.read_excel("large_data_file.xlsx")
    pylab.plot(df["time"],df["data"])
    xw.Plot(pl.gcf()).show("data")