草庐IT

compound-drawables

全部标签

android - 设置背景Drawable时填充在哪里?

我的EditText和ButtonView有这个问题,我有一个很好的填充让它们远离文本,但是当我改变背景时setBackgroundDrawable或setBackgroundResource填充永远丢失。 最佳答案 我发现添加一个9补丁作为背景资源会重置填充-虽然有趣的是,如果我添加了一个颜色或非9补丁图像,它没有。解决方案是在添加背景之前保存填充值,然后再设置它们。privateEditTextvalue=(EditText)findViewById(R.id.value);intpL=value.getPaddingLeft(

android - Drawable-hdpi、Drawable-mdpi、Drawable-ldpi Android

我正在使用Android1.5,但我现在已迁移到最新版本。所以Android1.5中只有一个“drawable”文件夹,但现在Android项目中有三个不同的文件夹用于存储图像。我发现这三个文件夹的一些文章说hdpi表示高dpimdpi表示中等dpildpi表示低dpi但是这三个文件夹的确切用途是什么?我什么时候应该使用特定的文件夹来存储图像? 最佳答案 要声明您希望用于不同屏幕的不同布局和位图,您必须将这些替代资源放在单独的目录/文件夹中。这意味着如果您为xhdpi设备生成200x200图像,您应该在150x150中为hdpi生成

android - Drawable-hdpi、Drawable-mdpi、Drawable-ldpi Android

我正在使用Android1.5,但我现在已迁移到最新版本。所以Android1.5中只有一个“drawable”文件夹,但现在Android项目中有三个不同的文件夹用于存储图像。我发现这三个文件夹的一些文章说hdpi表示高dpimdpi表示中等dpildpi表示低dpi但是这三个文件夹的确切用途是什么?我什么时候应该使用特定的文件夹来存储图像? 最佳答案 要声明您希望用于不同屏幕的不同布局和位图,您必须将这些替代资源放在单独的目录/文件夹中。这意味着如果您为xhdpi设备生成200x200图像,您应该在150x150中为hdpi生成

android - 如何缩小按钮上的可绘制对象?

如何使按钮上的可绘制对象更小?图标太大了,居然比按钮高。这是我正在使用的代码:上面是它应该看起来的样子,下面是它现在看起来的样子。我试过了,但没有显示图像。:-(Resourcesres=getResources();ScaleDrawablesd=newScaleDrawable(res.getDrawable(R.drawable.s_vit),0,10f,10f);Buttonbtn=(Button)findViewById(R.id.ButtonTest);btn.setCompoundDrawables(sd.getDrawable(),null,null,null);

android - 如何缩小按钮上的可绘制对象?

如何使按钮上的可绘制对象更小?图标太大了,居然比按钮高。这是我正在使用的代码:上面是它应该看起来的样子,下面是它现在看起来的样子。我试过了,但没有显示图像。:-(Resourcesres=getResources();ScaleDrawablesd=newScaleDrawable(res.getDrawable(R.drawable.s_vit),0,10f,10f);Buttonbtn=(Button)findViewById(R.id.ButtonTest);btn.setCompoundDrawables(sd.getDrawable(),null,null,null);

android - 为 EditText 的 Drawable 权限设置 onClickListener

这个问题在这里已经有了答案:HandlingclickeventsonadrawablewithinanEditText(41个回答)关闭8年前。在我的应用中,我有一个EditText,右侧有一个搜索图标。我使用了下面给出的代码。我想为分配给右侧可绘制对象的搜索图标图像设置onClickListenerEditText。怎么可能? 最佳答案 publicclassCustomEditTextextendsandroidx.appcompat.widget.AppCompatEditText{privateDrawabledrawab

android - 为 EditText 的 Drawable 权限设置 onClickListener

这个问题在这里已经有了答案:HandlingclickeventsonadrawablewithinanEditText(41个回答)关闭8年前。在我的应用中,我有一个EditText,右侧有一个搜索图标。我使用了下面给出的代码。我想为分配给右侧可绘制对象的搜索图标图像设置onClickListenerEditText。怎么可能? 最佳答案 publicclassCustomEditTextextendsandroidx.appcompat.widget.AppCompatEditText{privateDrawabledrawab

android - 比较android中的两个drawable

如何比较两个可绘制对象,我正在这样做但没有任何成功publicvoidMyClick(Viewview){DrawablefDraw=view.getBackground();DrawablesDraw=getResources().getDrawable(R.drawable.twt_hover);if(fDraw.equals(sDraw)){//Notcoming}} 最佳答案 更新https://stackoverflow.com/a/36373569/1835650getConstantState()效果不佳还有一种比较方

android - 比较android中的两个drawable

如何比较两个可绘制对象,我正在这样做但没有任何成功publicvoidMyClick(Viewview){DrawablefDraw=view.getBackground();DrawablesDraw=getResources().getDrawable(R.drawable.twt_hover);if(fDraw.equals(sDraw)){//Notcoming}} 最佳答案 更新https://stackoverflow.com/a/36373569/1835650getConstantState()效果不佳还有一种比较方

android - drawable-xxhdpi 的正确尺寸图标是多少?

我们知道,正确大小的图标:*drawable-ldpi(120dpi,Lowdensityscreen)-36pxx36px*drawable-mdpi(160dpi,Mediumdensityscreen)-48pxx48px*drawable-hdpi(240dpi,Highdensityscreen)-72pxx72px*drawable-xhdpi(320dpi,Extra-highdensityscreen)-96pxx96px在果冻bean上,可以支持drawable-xxhdpi。那么正确大小的图标是什么? 最佳答案