2012-02-25 104 views
0

我正在尝试创建一个按钮。我之前做过这样的事情,但现在我得到了一个错误,我无法找出它是什么。我想我已经得到了在XML文件中的问题,但无法找到它:SAndroid - 布局错误

因此,有我的XML:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageButton 
     android:id="@+id/login" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="115dp" 
     android:layout_marginTop="80dp" 
     android:src="@drawable/login_button" /> 
</RelativeLayout> 

我试图实施某种Facebook登录。我正在使用easyfacebook sdk。因此,这里是java的代码,我想实现的登录按钮:

http://pastebin.com/brHmJKs1

我得到的消息是:

W/WebCore的(29941)后,无法获得viewWidth第一布局

E/SkLayout_wtle(29941):布局错误:106宽度:0 ellipsizedWidth:0

W/InputManagerService(1171):窗口已经聚焦,忽略聚焦增益的:com.android.internal。 view.IInputMethodClient $ S tub $ Proxy @ 405c4e68

+0

你能更具体吗? 什么是ImageButton的父视图。 何时何地发生此错误。 我们可以看到代码片段,因此更易于调试。 – Pankaj 2012-02-25 16:27:21

+0

对不起。当我点击按钮时,我会收到这些消息。 – user1162316 2012-02-25 16:31:06

+0

第5行是否要读取“... 80dp”而不是“... 80sp”? – Jon 2012-02-25 16:34:58

回答

1

首先关闭你的第一个LinearLayout在最后一行。第二,删除RelativeLayout,这是没有用的,然后尝试我希望你会获得成功。

+0

它关闭了,我粘着代码时我是不注意的。当我删除RelativeLayout时,我看不到按钮,所以这是我的虚拟解决方案 – user1162316 2012-02-25 16:47:36

+0

他已经清除他已经使用过的 和其他的东西是没有错的XML我试过了。 代码本身有问题 – Pankaj 2012-02-25 16:48:30

+0

尝试使用LayoutBheight =“wrap_content”和layout_width =“wrap_content”的imagebutton.See是否正在工作,然后可能是高度和宽度的问题。只需尝试一下,然后我们会看到。 – 2012-02-25 16:51:08