1

タイトルのとおり、ソーシャルログインボタンを水平のLinearLayout内で整列させることに問題があります。私はこれを通常のボタンで試してみたところ、完全に一致していますが、FacebookとGoogleのボタンに戻るたびに何らかの理由で位置がずれてしまいます。ソーシャル(GoogleとFacebook)のボタンが水平のLinearLayoutに揃っていません

これは、彼らがデザインビューでどのように見えるかです:

enter image description here

そして、これは私のXMLコードです:あなたのLinearLayoutにlayout_gravity = "センター":

<LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 

      <com.facebook.login.widget.LoginButton 
       android:id="@+id/facebookButton" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_gravity="center_horizontal" 
       android:paddingTop="10dp" 
       android:paddingBottom="10dp" 
       android:layout_weight="1" 
       android:layout_marginStart="16dp" /> 


      <com.google.android.gms.common.SignInButton 
       android:id="@+id/googleButton" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_gravity="center_horizontal" 
       android:layout_weight="1" 
       android:layout_marginEnd="13dp"/> 


     </LinearLayout> 

答えて

1

は、Androidを入れてみてください。

+0

多分ちょうどアンドロイド:重力= "中心"ですか? – Ekalips

+0

はい、実際は非常にばかげた間違いです。私がしなければならなかったのはアンドロイドを変更することでした:layout_gravity = "centre_horizo​​ntally" = "center" - ありがとう! – AndroidDevBro

1
<LinearLayout android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="center" 
    android:weightSum="2" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <com.facebook.login.widget.LoginButton 
     android:id="@+id/facebookButton" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:paddingTop="10dp" 
     android:paddingBottom="10dp" 
     android:layout_weight="1" 
     android:layout_marginStart="16dp" /> 


    <com.google.android.gms.common.SignInButton 
     android:id="@+id/googleButton" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:layout_marginEnd="13dp"/> 


</LinearLayout> 
関連する問題