Tag: 复合绘制

是否有可能使用VectorDrawable在button和TextViews使用android:DrawableRight?

当我在textview或imageview中使用VectorDrawable资产时,当使用“android:DrawableRight”/“android:DrawableEnd”/“android:DrawableStart”/“android:DrawableLeft”时,运行时崩溃。 该应用程序将编译罚款没有任何警告。 我在用 Gradle 1.5 支持库23.2('com.android.support:appcompat-v7:23.2.0') 我发现,虽然是我可以编程方式分配SVG的Java没有这样的崩溃。 TextView tv = (TextView) findViewById(R.id.textView); tv.setCompoundDrawablesWithIntrinsicBounds(null,null, getResources().getDrawable(R.drawable.ic_accessible_white_36px),null); (我怀疑这是23.2的支持库错误。) 但有没有可能使用drawableRight等SVG资产? 这是我的布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="au.com.angryitguy.testsvg.MainActivity"> <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableRight="@drawable/ic_accessible_white_36px" android:background="@color/colorPrimary" android:textColor="#FFFFFF" android:textSize="22sp" android:text="Hello World!"/> </RelativeLayout> 这是我的活动 package au.com.angryitguy.testsvg; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public […]

我怎样才能缩小button上的drawable?

我怎样才能使一个button上的drawable更小? 图标太大,实际上高于button。 这是我正在使用的代码: <Button android:background="@drawable/red_button" android:drawableLeft="@drawable/s_vit" android:id="@+id/ButtonTest" android:gravity="left|center_vertical" android:text="S-SERIES CALCULATOR" android:textColor="@android:color/white" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:drawablePadding="10dp"> </Button> 鞋面是它应该看起来如何,它现在看起来如何。 我试过这个,但没有显示图像。 🙁 Resources res = getResources(); ScaleDrawable sd = new ScaleDrawable(res.getDrawable(R.drawable.s_vit), 0, 10f, 10f); Button btn = (Button) findViewById(R.id.ButtonTest); btn.setCompoundDrawables(sd.getDrawable(), null, null, null);

在EditText中处理drawable上的click事件

我已经使用以下XML在EditText小部件中添加了文本的图像权限: <EditText android:id="@+id/txtsearch" … android:layout_gravity="center_vertical" android:background="@layout/shape" android:hint="Enter place,city,state" android:drawableRight="@drawable/cross" /> 但是我想在点击embedded图像时清除EditText 。 我该怎么做?