Eclipse内容辅助在Android布局中无法正常工作

5
每当我在android.support.v4.widget.DrawerLayout内部的ViewGroup中有视图时,Eclipse的自动完成开始工作异常。它不显示大多数属性。
例如:DrawerLayout -> LinearLayout -> ImageView

Autocomplete not working

在前面的截图中,您可以看到我输入了“android:scale...”,但IDE的智能感知没有显示ImageView的android:scaleType
如果我使用Eclipse的属性窗口进行ImageView的操作,我会发现它只显示“View”的基本属性(而不是ImageView的属性):

Eclipse Property Window

现在,如果ImageView不是DrawerLayout的后代,并且我将其放在其他地方,则自动完成功能正常:

Now It Works...

我看到了相关的问题,比如:

但是它们已经很久没有答案了...

对于我在DrawerLayout中添加的视图(无论是TextView、EditText还是Button...),内容辅助功能都不起作用。它只建议“基本”属性。

有人知道为什么会出现这种情况或如何解决吗?

示例布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/some_image" />
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/drawer_view"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start" >
    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

1
当使用支持包Widgets时,这是一个常见的情况 - http://stackoverflow.com/questions/22537733/no-layout-width-attribute-shown-in-option-list-when-using-drawerlayout-in-adt - Dileep Perla
2个回答

1

仅为了给这个已有5个月历史的问题提供一些解决方案,我会引用并链接到Atul O Holic的答案。感谢Dileep Perla指出了这一点。

当使用支持包小部件时,这是一个常见的情况(也是奇怪的情况)。

在这里,您正在使用android.support.v4.widget.DrawerLayout,因此会出现问题。这种情况经常发生。

您还可以尝试此处提到的几个选项。


0
我发现在这种情况下使用 <include> 标签非常方便。只需将抽屉中的布局放入单独的布局文件中,然后在抽屉布局中包含它即可。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接