Unable to add com.facebook.share.widget.Sharebutton to Layout XML

China☆狼群 提交于 2019-12-05 11:40:23

Add this line in the main layout

xmlns:facebook="http://schemas.android.com/apk/res-auto"

like this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

Yes, com.facebook.share.widget.ShareButton is correct XML element. It will not be rendered by preview of XML layout, but don't worry about it. The app will compile without problems, and running app will show it properly.

<com.facebook.share.widget.ShareButton
        android:id="@+id/shareButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!