
[英]Facebook login button change height and width in Android Studio
[英]Can't change the height of my Facebook login button (Android)
我正在尝试更改 Facebook 登录按钮的尺寸 - 但是我只能更改按钮的宽度,并且出于某种原因高度始终保持不变。
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="Log in with Facebook"
android:id="@+id/login_button"
android:layout_width="240dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"/>
任何想法为什么?
我还尝试将按钮放在自己的 LinearLayout 中,并将宽度和高度设置为 match_parent,但高度仍然保持不变。
感谢任何帮助!
对于 Facebook SDK v4.x(或者不使用单独的 xml 样式)
按钮的高度由它的 padding 和 textSize 决定。
因此,如果您想增加按钮大小,请执行以下操作
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="Log in with Facebook"
android:id="@+id/login_button"
android:textSize="15sp"
android:paddingTop="15sp" <!--increase more until it matches ur requirement -->
android:paddingBottom="15sp">
希望能帮助到你!!
您可以创建自定义按钮。 为此,请在 style.xml 中创建自定义样式:
<style name="CustomFbButton">
<item name="android:background">THE IMAGE OF FB BUTTON</item>
<item name="android:layout_height">300dp</item>
<item name="android:layout_width">65dp</item>
<item name="android:layout_marginTop">If you need</item>
<item name="android:layout_marginBottom">If you need</item>
<item name="android:layout_gravity">center_horizontal</item> </style>
现在您可以放入您的 xml(您的活动(按钮所在的位置)):
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="Log in with Facebook"
android:id="@+id/login_button"
style="@style/CustomFbButton/>
使用下面的代码试试这个代码。 我用过它,它对我有用。
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="Log in with Facebook"
android:id="@+id/login_button"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_gravity="center_horizontal"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.