0

我想在我的 android 应用程序中添加三个社交网络登录按钮 Facebook、Twitter 和 Google plus。好消息是我已经添加了所有具有功能的按钮,但我面临的问题是如何调整所有这些按钮的高度具有相同的高度。我可以添加填充来调整高度,但我认为这不是正确的方法。如果有人以前遇到过这个问题并解决过,请与我分享。

这是我到目前为止所做的代码看起来高度问题已解决,但登录文本似乎不合适。

<RelativeLayout
    android:id="@+id/line_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/elevation"
        android:layout_centerVertical="true"
        android:background="@color/grey" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@color/black"
        android:text="OR"
        android:textColor="@color/white" />
</RelativeLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/line_layout"
    android:layout_centerHorizontal="true"
    android:orientation="vertical">

    <TextView
        android:id="@+id/info_text_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="info here" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <com.facebook.login.widget.LoginButton
            android:id="@+id/login_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:paddingBottom="20dp"
            android:paddingTop="20dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="@dimen/screen_padding_lr"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <com.twitter.sdk.android.core.identity.TwitterLoginButton
            android:id="@+id/twitter_login_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:paddingBottom="10dp"
            android:paddingTop="10dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="@dimen/screen_padding_lr"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <com.google.android.gms.common.SignInButton
            android:id="@+id/sign_in_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal" />
    </LinearLayout>

</LinearLayout>

4

1 回答 1

0

您必须使用固定的dp高度,您可以将不同的尺寸放在不同的值文件夹中以支持多个设备

于 2016-04-15T11:39:49.517 回答