如何自定义Facebook和谷歌登录按钮

时间:2014-01-03 12:55:07

标签: android button facebook-login google-login

我正在尝试构建一个用户可以使用Google或Facebook帐户注册的应用程序 我也想让我的应用程序干净简单,所以我不想要默认的登录按钮。 我偶然发现了9gag登录页面,我喜欢他们所做的。 任何人都可以告诉我如何制作像他们一样的按钮?

enter image description here

这是我的代码:

        <RelativeLayout
        android:id="@+id/btnFaceBookLogin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:background="@color/facebook_blue">


      <ImageView
         android:id="@+id/facebook_icon"
         android:layout_width="30dp"
         android:layout_height="30dp"

         android:layout_alignParentLeft="true"
         android:layout_centerVertical="true"
         android:layout_marginLeft="11dp"
         android:contentDescription="@string/write_title"
         android:src="@drawable/com_facebook_inverse_icon" />


     <LinearLayout
         android:layout_width="1dp"
         android:layout_height="35dp"
                      android:layout_centerVertical="true"

         android:layout_alignTop="@+id/facebook_icon"
         android:layout_toRightOf="@+id/facebook_icon"
         android:layout_marginLeft="4dp"
         android:background="@android:color/darker_gray"
         android:orientation="vertical" >
     </LinearLayout>

    </RelativeLayout>

1 个答案:

答案 0 :(得分:0)

试试这个 -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/facebook"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="24dp"
        android:src="@drawable/ans"/>

    <ImageView
        android:id="@+id/Google"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/facebook"
        android:src="@drawable/ans" />

    <EditText
        android:id="@+id/userName"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Google"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="18dp"
        android:ems="10"
        android:inputType="textPersonName" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/userName"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="34dp"
        android:ems="10"
        android:inputType="textPersonName" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/password"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="34dp"
        android:text="Sign In" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="21dp"
        android:text="Forget Pass" 
        android:gravity="center"/>

</RelativeLayout>
相关问题