2017-02-10 38 views
4

我想在我的佈局之一,但可悲的是使用com.google.android.gms.common.SignInButton,沒有任何有價值的理由,按鈕內的文本並不想在中心。Android的 - 谷歌SignInButton文本不居中

這裏是如何看:

enter image description here

的XML是非常簡單的,我試着用保證金/填充/重力播放/ ......但沒有任何工程居中文字:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include layout="@layout/toolbar" /> 

    <com.google.android.gms.common.SignInButton 
     android:id="@+id/button_google_sign_in" 
     android:layout_width="200dp" 
     android:layout_height="60dp" 
     android:layout_centerInParent="true" /> 

</RelativeLayout> 

編輯:

即使是一個完全空白的活動,此按鈕顯示不正確......我瘋了?

enter image description here

有人偷已經遇到這個問題?

謝謝

+1

什麼是你的谷歌播放服務的版本? –

+0

請發佈'工具欄'佈局。我使用了Google SignIn按鈕,它對我來說非常合適。所以想要檢查'工具欄'佈局是否搞亂了某些東西 – Dibzmania

+0

@ A.Badakhshan'com.google.android.gms:play-services-auth:10.0.1' – Valentin

回答

3
  • 檢查谷歌播放服務版本, 我寧願你使用compile 'com.google.android.gms:play-services-auth:9.8.0'作爲document
  • 入住提到你在你的演員@ SDK管理器播放服務的任何更新
  • 要確認問題是無論你的安裝的東西,你可以在另一臺PC上運行你的項目
  • 最後,如果你不能解決問題去替代Customizing the Sign-In Button

這谷歌登入按鈕實際上並不執行任何特殊的功能,但也有法律界,因爲你要使用相同的背景作爲替代,你可以去定製登入按鈕其背景爲image

enter image description here

的谷歌登入按鈕對用戶進行認證。請注意,這 類只處理視覺方面的按鈕。爲了 觸發一個動作,寄存器使用 setOnClickListener(OnClickListener)的監聽器。

https://developers.google.com/android/reference/com/google/android/gms/common/SignInButton

0

使用本

compile 'com.google.android.gms:play-services-auth:9.8.0' 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 


<com.google.android.gms.common.SignInButton 
    android:id="@+id/button_google_sign_in" 
    android:layout_width="200dp" 
    android:layout_height="60dp" 
    android:layout_centerInParent="true" /> 

enter image description here

-1
<com.google.android.gms.common.SignInButton 
       android:id="@+id/sign_in_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_gravity="center" 
       /> 


Use android:layout_gravity="center" 
+0

@Valentin使用它的工作... –