Android,如何更改默认的facebook按钮

时间:2015-07-29 02:29:04

标签: java android facebook android-widget

我正在使用facebook登录。我正在尝试更改按钮,但它现在不起作用: 我想把高度设为100dp。

登录页面xml:

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFF">



        <ImageView android:layout_width="fill_parent"
                   android:layout_height="fill_parent"
                   android:src="@drawable/splash_screen"
                   android:scaleType="centerCrop"/>


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

            <TextView
                android:text=""
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/label"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:textColor="#FFF"/>


            <com.gc.materialdesign.views.ButtonFlat
                android:id="@+id/bt_skip_login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Skip Login"
                android:onClick="autoLogin"
                android:layout_above="@+id/login_button"
                android:layout_centerHorizontal="true"
                android:te

xtColor="#FFF"/>

        <com.facebook.login.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/login_button"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:scaleType="centerInside"
            style="@style/FacebookLoginButton"/>
    </RelativeLayout>

</RelativeLayout>

风格:

 <style name="FacebookLoginButton">
        <item name="android:layout_marginTop">10dp</item>
        <item name="android:layout_marginBottom">0dp</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">90dp</item>
    </style>

我想看起来像这样,但只是为了填补宽度。

enter image description here

我已更新我的代码,仍然没有更改登录bt

1 个答案:

答案 0 :(得分:0)

如果您想根据自己的要求设置自定义Facebook按钮,最好的选择是隐藏Facebook登录按钮并自定义原生Android按钮并将其置于原始Facebook登录按钮上方。现在点击新定制的按钮调用 loginbtn.performClick(); 。通过这种方式,您也可以更改Button的文本。

相关问题