如何cutomize在Android Studio的Twitter和Facebook的登录按钮 [英] How to cutomize Twitter and Facebook Login Buttons on Android Studio
问题描述
我有一个应用程序中,我要调整和定制的Facebook和Twitter的按钮。当我调整它们的大小更小,按键看上去小,但文本仍大,不能完全显示。
I have an app in which I want to align and customize Facebook and Twitter buttons. When I resize them smaller, the button looks smaller but the text is still big and doesn't show completely.
在code是这样的:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center_horizontal"
android:layout_marginTop="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_weight="1">
<com.twitter.sdk.android.core.identity.TwitterLoginButton
android:id="@+id/twitter_login_button"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="left"
android:layout_marginRight="5dp"
android:layout_weight="1" />
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="right"
android:layout_marginLeft="5dp"
android:layout_weight="1" />
</LinearLayout>
我需要10美誉张贴图像,以便继承人的链接的
<一个href="https://scontent-lax3-1.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/11863330_10153107579846958_1570243894288322513_n.jpg?oh=15ff7878098d2e005995de9f17312ca8&oe=56736931" rel="nofollow">https://scontent-lax3-1.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/11863330_10153107579846958_1570243894288322513_n.jpg?oh=15ff7878098d2e005995de9f17312ca8&oe=56736931
正如你所看到的,微博的文字看起来太大了,它可以完全显示。是否可以定制按钮,像更改文本的大小或带走的应用程序图标?
As you can see, twitter's text looks too big and it can be shown completely. Is it possible to customize buttons, like change the size of the text or taking away the app icon?
推荐答案
在你的XML执行以下操作:
In your xml do the following:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center_horizontal"
android:layout_marginTop="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_weight="1">
<Button
android:id="@+id/fb_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Facebook"
android:layout_weight="1"
/>
<Button
android:id="@+id/tweet_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Twitter"
android:layout_weight="1"
/>
<com.twitter.sdk.android.core.identity.TwitterLoginButton
android:id="@+id/twitter_login_button"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="left"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:visibility="gone"
/>
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="right"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
您可以根据您的需要自定义按钮的布局。
You can customise the layouts of button according to your requirements.
在你的code:
TwitterLoginButton tweet_Login=(TwitterLoginButton) findViewById(R.id.twitter_login_button);
LoginButton fb_login=(LoginButton) findViewById(R.id.login_button);
Button fb_button=(Button) findViewById(R.id.fb_button);
Button tweet_button=(Button) findViewById(R.id.tweet_button);
fb_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fb_login.performClick();
}
});
tweet_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tweet_Login.performClick();
}
});
这篇关于如何cutomize在Android Studio的Twitter和Facebook的登录按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!