【问题标题】:Share icon (vector) shows in design but not in app共享图标(矢量)显示在设计中但不在应用程序中
【发布时间】:2017-04-18 19:08:22
【问题描述】:

我使用矢量在卡片视图中创建共享图标。

在 HolderClass 中实现

class CommasHolder extends RecyclerView.ViewHolder{
SimpleDraweeView commasImage;
ImageButton shareButton;

public CommasHolder(View cardView){
    super(cardView);
    commasImage = (SimpleDraweeView) cardView.findViewById(R.id.cardview_image);
    shareButton = (ImageButton) cardView.findViewById(R.id.share_button);
}
}

布局

    <ImageButton
        android:id="@+id/share_button"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginRight="10dp"
        android:layout_gravity="bottom|end"
        card_view:srcCompat="@drawable/ic_share_black_24dp"/>

矢量

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#FF000000"
    android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>

【问题讨论】:

    标签: java android vector


    【解决方案1】:

    你有没有把这个添加到你的 Gradle 文件中

     android {  defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }   }  
    

    【讨论】:

    • 是的,我在 gradle 文件中添加了它
    猜你喜欢
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多