标签: android-vectordrawable

VectorDrawable已缩放且不清晰

Android Studio中的向量xml:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
    android:fillColor="#FF000000"
    android:pathData="M12,15C7.58,15 4,16.79 4,19V21H20V19C20,16.79 16.42,15 12,15M8,9A4,4 0,0 0,12 13A4,4 0,0 0,16 9M11.5,2C11.2,2 11,2.21 11,2.5V5.5H10V3C10,3 7.75,3.86 7.75,6.75C7.75,6.75 7,6.89 7,8H17C16.95,6.89 16.25,6.75 16.25,6.75C16.25,3.86 14,3 14,3V5.5H13V2.5C13,2.21 12.81,2 12.5,2H11.5Z" />
Run Code Online (Sandbox Code Playgroud)

结果:

在此处输入图片说明

更改24dp96dp,结果:

在此处输入图片说明

Android Studio中的菜单xml:

...
<!-- Sperren -->
<TextView
    android:id="@+id/suppress_button"
    style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
    android:drawableLeft="@drawable/ic_assignment_return"
    android:drawableStart="@drawable/ic_assignment_return"
    android:text="Sperren" />

 <!-- IH-Auftrag -->
 <TextView
    android:id="@+id/setup_maintenance_order_button"
    style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
    android:drawableLeft="@drawable/ic_ih_auftraege"
    android:drawableStart="@drawable/ic_ih_auftraege"
    android:text="IH-Auftrag" />
    ...
Run Code Online (Sandbox Code Playgroud)

所以我现在的问题是,如何像svg一样自动更改大小?

android android-vectordrawable

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

淡出并使用ObjectAnimator翻译VectorDrawable

我试图让AnimatedVectorDrawable同时淡出和翻译.我做了一个ObjectAnimator资源:

<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
    android:propertyName="translationX"
    android:duration="@+string/animtime"
    android:valueFrom="0"
    android:valueTo="150"
    android:valueType="floatType"/>
<objectAnimator
    android:propertyName="alpha"
    android:duration="@+string/animtime"
    android:valueFrom="255"
    android:valueTo="0"
    android:valueType="intType"/>
Run Code Online (Sandbox Code Playgroud)

然后有针对性一个VectorDrawableObjectAnimation:

<target
    android:name="disgust"
    android:animation="@anim/fadetransout" />
Run Code Online (Sandbox Code Playgroud)

VectorDrawable是资源文件<group>中的一个VectorDrawable.

但是当我开始动画时,什么都没发生.我究竟做错了什么?

我在堆栈跟踪中发现了这个:

Method setTranslationX() with type float not found on target class class android.graphics.drawable.VectorDrawable$VGroup
Method setAlpha() with type int not found on target class class android.graphics.drawable.VectorDrawable$VGroup
Run Code Online (Sandbox Code Playgroud)

它与此有关吗?

如果这是不可能的,还有另一种方法可以让我VectorDrawable淡化和翻译吗?

谢谢.

android android-animation objectanimator android-vectordrawable

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

使用 Firebase UI 时,请为 VectorDrawableCompat 配置您的构建

我面临这个错误:

Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
Run Code Online (Sandbox Code Playgroud)

但是添加Firebase UI依赖项后出现此错误:

compile 'com.firebaseui:firebase-ui:0.4.3'
Run Code Online (Sandbox Code Playgroud)

我已经看过这个和这篇文章,但似乎没有什么对我有用,即使我的项目中没有矢量绘图,但我想知道为什么它给我这个错误消息。下面是我的日志:

10-03 04:58:29.699 1256-1270/system_process E/WindowManager: Starting window AppWindowToken{b13967c8 token=Token{b1990890 ActivityRecord{b1778df8 u0 pixsor.app.huzykamz.pixoradmin/.MainActivity t8}}} timed out
10-03 05:03:21.954 1256-1326/system_process A/ActivityManager: Service ServiceRecord{b199ac38 u0 pixsor.app.huzykamz.pixoradmin/com.google.android.gms.measurement.AppMeasurementService} in process ProcessRecord{b12b8bd0 21551:pixsor.app.huzykamz.pixoradmin/u0a62} not same as in map: null
10-03 05:06:42.187 25698-25698/? E/memtrack: Couldn't load memtrack module (No such file or directory)
10-03 05:06:42.187 25698-25698/? …
Run Code Online (Sandbox Code Playgroud)

android firebase firebaseui android-vectordrawable

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

激活和停用drawable中的某些路径

我正在尝试制作一个刽子手应用程序并创建了一个刽子手SVG文件,其中包含向量中每个身体部位的单独路径.

有没有办法打开和关闭这些路径所以我不需要为刽子手游戏的每个阶段制作文件的几个副本?

android android-vectordrawable

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

Android使用矢量可绘制的图像在android &lt;5中的customview中的图像

我有一个CustomView与类TextViewImageView类似

public class CustomView extends LinearLayout {
    private ImageView imgImage;
    ...

    public CustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(attrs);
    }
    private void init(AttributeSet attrs) {
        LayoutInflater.from(getContext()).inflate(R.layout.custom_layout, this, true);
        imgImage = (ImageView) findViewById(R.id.image);

        TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewStyle);
        Drawable drawable = ta.getDrawable(R.styleable.CustomViewStyle_image); // CRASH LINE

        ta.recycle();
        imgImage.setBackground(drawable);
    }
}
Run Code Online (Sandbox Code Playgroud)

style.xml

<declare-styleable name="CustomViewStyle">
     <attr format="string" name="text"/>
     <attr format="reference" name="image"/>
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)

build.gradle

android {
  defaultConfig {
    ...
    vectorDrawables.useSupportLibrary = true
  } …
Run Code Online (Sandbox Code Playgroud)

android android-vectordrawable

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

自定义视图上的可绘制标记向量无效

我创建了一个带有图像图标的自定义视图,并像这样初始化它:

XML

IconFieldLinearLayout.java

private void initAttr(Context context, AttributeSet attrs) {

        if (attrs != null) {
            TypedArray a = context.obtainStyledAttributes(attrs,
                    R.styleable.IconFieldLinearLayout, 0, 0);



            Drawable icon = a.getDrawable(R.styleable.IconFieldLinearLayout_icon);
            boolean tintIcon = a.getBoolean(R.styleable.IconFieldLinearLayout_tintIcon, true);
            int color = a.getColor(R.styleable.IconFieldLinearLayout_tintColor, Color.WHITE);

            a.recycle();
            initIcon(context, icon, tintIcon, color);
        } else {
            initIcon(context, mDefaultDrawable, true, Color.WHITE);
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我使用这个 drawable 在 Android 4.3 上运行它时:

<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="#ffff"
        android:pathData="M12,5.9c1.16,0 2.1,0.94 2.1,2.1s-0.94,2.1 -2.1,2.1S9.9,9.16 9.9,8s0.94,-2.1 2.1,-2.1m0,9c2.97,0 6.1,1.46 6.1,2.1v1.1L5.9,18.1L5.9,17c0,-0.64 3.13,-2.1 6.1,-2.1M12,4C9.79,4 8,5.79 8,8s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 …
Run Code Online (Sandbox Code Playgroud)

android android-vectordrawable

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

android 中的 SVG/VectorDrawable 问题

我在我的 Android 项目中使用了 svg 文件。Android 4.4 或更低版本存在问题。我已经尝试过这些解决方案

  1. app:srcCompat,
  2. vectorDrawables.useSupportLibrary = true 在 gradle 文件和
  3. AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);BaseActivity.
除了 gridview,图像不会显示在 app 中

svg android android-support-library android-5.0-lollipop android-vectordrawable

0
推荐指数
1
解决办法
1266
查看次数

如何在心形drawable xml中添加边框(描边)线

  • 如下我绘制可绘制的 xml 像心形
  • 但我想添加边框线,如(描边)
  • 我遇到一些困难如何添加该行

    <path
        android:fillColor="#a39f9f"
        android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
    
    Run Code Online (Sandbox Code Playgroud)

xml android android-shape android-vectordrawable

0
推荐指数
1
解决办法
1847
查看次数