2017-02-10 13 views
4

私は自分のレイアウトの1つにcom.google.android.gms.common.SignInButtonを使用したいと思いますが、悲しいことに、貴重な理由なしに、ボタンの中にあるテキストは中央になりたくありません。ここでAndroid - Google 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> 

EDIT:

でも完全に空の活動と、このボタンは正しく表示されない...私はクレイジーですか?

enter image description here

誰かがすでにこの問題が発生していますか?

は私がdocument

  • で述べたようにcompile 'com.google.android.gms:play-services-auth:9.8.0'を使用するためにあなたを好むだろう、 をお使いのGoogle Play-サービスのバージョンを確認し、あなたに

  • +1

    あなたのGoogle Playのサービスのバージョンは何ですか? –

    +0

    の 'toolbar'レイアウトを投稿してください。私はGoogleのサインインボタンを使用して、それは私のために完全に動作します。だから 'ツールバーのレイアウトが何かを台無しにしているかどうかチェックしたかったのです – Dibzmania

    +0

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

    答えて

    3
    • ありがとうあなたがSDKマネージャ@あなたのエキストラでプレイサービスのためのアップデートを持ってチェック
    • 問題を確認するには、インストールしたものを別のPCでプロジェクトを実行することができます。
    • 最後に、問題を解決できない場合はCustomizing the Sign-In Button

    このGoogleはサインインボタン、実際に特別な機能を実行しますが、法的な境界が存在していない、あなたはカスタムサインインボタンのために行くことができる代替手段として同じ背景を使いたいので、これは背景をimageとして保持します。

    enter image description here

    Googleのサインインボタンユーザを認証します。この クラスは、ボタンの視覚的側面のみを処理することに注意してください。 アクションをトリガーするには、 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はこの仕事を使っています... –

    関連する問題