开发者

<include> tag isn't accurately displaying it's content

I have a layout menu which contains this:

<RelativeLayout android:id="@+id/computersMenu"
                android:layout_width="50dp"
                android:layout_height="50dp">
        <include        layout="@layout/component_add_button"
                     开发者_开发百科   android:id="@+id/imagebutton_add_client"/>  
</RelativeLayout>

component_add_button.xml:

<?xml version="1.0" encoding="utf-8"?>
<ImageView  xmlns:android="http://schemas.android.com/apk/res/android"  
            android:src="@drawable/ic_menu_add"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:scaleType="center"/>    

Looking at the preview (EDIT: I mean the "Graphical Layout" tab of the xml editor in eclipse which uses the same rendering engine as all devices AFAIK) of component_add_button.xml you can see the image. Great. On the page which is including it it isn't displaying (although it does give you a selectable space where the image should be).

This seems like a really simple example that "should just work". The include tag has always seemed really flaky to me - I'm wondering if I'm missing something in terms of how it actually works...?


As your answer states, the eclipse preview does not display included layouts.

The simplest way to avoid doubt or mistakes in markup when "including" layout's is to design in the original layout then right click the view you wish to extract and select Extract include... from the menu


On a device this functionality worked fine. This seems like a bug in the "Graphical Layout" tab of the layout xml editor shipped with android-sdk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜