小编Pop*_*Pop的帖子

在Facebook按钮上添加圆角

我正在尝试自定义Android中的facebook sdk附带的按钮.我希望它有圆角而不是普通的角落,为了实现这一点我从这里尝试了答案,我所做的基本上是我在styles.xml中为我的facebook按钮添加了一个样式:

   <style name="FacebookLoginButton">
    <item name="android:background">@drawable/fbshapebtn</item>
    <item name="android:textSize">18sp</item>
    <item name="android:gravity">center</item>
</style>
Run Code Online (Sandbox Code Playgroud)

作为背景,我从我的drawable中引用了一个xml,我在其中定义了我的角落:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
    <corners
        android:bottomRightRadius="10dp"
        android:bottomLeftRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

这是我的主要布局,其中我引用了我的样式xml.

  <com.facebook.login.widget.LoginButton
        android:id="@+id/login_button"
        style="@style/FacebookLoginButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView"
        android:layout_alignLeft="@+id/button2"
        android:layout_alignStart="@+id/button2"
        android:layout_marginBottom="11dp"
        android:layout_alignRight="@+id/button2"
        android:layout_alignEnd="@+id/button2" />
Run Code Online (Sandbox Code Playgroud)

该按钮似乎没有角落,但它很奇怪,因为我定义的textSize似乎被应用,所以我不知道究竟是什么错.

xml android android-layout facebook-sdk-4.0

3
推荐指数
1
解决办法
2292
查看次数

标签 统计

android ×1

android-layout ×1

facebook-sdk-4.0 ×1

xml ×1