Tag: android drawable

Android Studio可绘制文件夹

在Android Studio中,我无法弄清楚应该在哪里放置图片。 可绘制的文件夹不分解为drawable-hdpi,drawable-ldpi等。我看到另外一个问题,并且问题的答案是切换到Project视图而不是Android视图,但是drawable只有一个文件夹。 有mipmap-hdpi,mipmap-ldpi等,但是人们只是说这只是应用程序图标。 我很困惑。

调整浮动操作button(fab)的图标大小

新的浮动button应该是56dp x 56dp ,其中的图标应该是24dp x 24dp 。 所以图标和button之间的空间应该是16dp 。 <ImageButton android:id="@+id/fab_add" android:layout_width="56dp" android:layout_height="56dp" android:layout_gravity="bottom|right" android:layout_marginBottom="16dp" android:layout_marginRight="16dp" android:background="@drawable/ripple_oval" android:elevation="8dp" android:src="@drawable/ic_add_black_48dp" /> ripple_oval.xml <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item> <shape android:shape="oval"> <solid android:color="?android:colorAccent" /> </shape> </item> </ripple> 这是我得到的结果: 我使用了\ material-design-icons-1.0.0 \ content \ drawable-hdpi \ ic_add_black_48dp.png中的图标 https://github.com/google/material-design-icons/releases/tag/1.0.1 如何使button内的图标大小 完全按照指导原则进行描述? http://www.google.com/design/spec/components/buttons.html#buttons-floating-action-button

如何将图像添加到Android Studio中的“drawable”文件夹?

我需要添加一个图像的res/drawable文件夹… 当我selectnew > image asset ,它出来一个对话框selectAsset Type … 我如何添加一个图像到res/drawable文件夹?

调用setCompoundDrawables()不会显示Compound Drawable

在我调用setCompoundDrawables方法后,复合Drawable不显示.. Drawable myDrawable = getResources().getDrawable(R.drawable.btn); btn.setCompoundDrawables(myDrawable, null, null, null); 有什么想法吗?

android:drawableLeft margin和/或padding

是否有可能为我们添加的android:drawableLeft的图像设置边距或填充?

如何解决:android.app.RemoteServiceException:从包中发布的错误通知*:无法创build图标:StatusBarIcon

我在崩溃日志中看到以下exception: android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn't create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 ) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1456) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5487) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) 我使用以下方法通过AlarmManager通过PendingIntent从IntentService发布我的通知。 在这里传递的所有值都来自PendingIntent / IntentService中的bundle extras。 /** * Notification * * @param c * @param intent * @param […]

与底部中风的Android形状

我需要创build一个android形状,以便只有底部有中风(虚线)。 当我尝试以下时,笔画将中心的形状一分为二。 有谁知道如何去正确的? 笔画需要是底线/边框。 我正在使用该形状作为TextView的背景。 请不要紧,为什么我需要它。 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="#1bd4f6" /> </shape> </item> <item> <shape android:shape="line" > <padding android:bottom="1dp" /> <stroke android:dashGap="10px" android:dashWidth="10px" android:width="1dp" android:color="#ababb2" /> </shape> </item> </layer-list>

以编程方式在TextView中设置左边的drawable

我有一个XML文本在这里。 <TextView android:id="@+id/bookTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:drawableLeft="@drawable/checkmark" android:gravity="center_vertical" android:textStyle="bold" android:textSize="24dip" android:maxLines="1" android:ellipsize="end"/> 正如你所看到的,我将DrawableLeft设置为xml。 我想改变代码中的drawable。 有没有办法去做这件事? 或者在文本视图的代码中设置drawableLeft?

使用XML绘制的垂直线

我试图找出如何定义一个垂直线(1dp厚)作为一个可绘制的。 做一个水平的,这是非常简单的: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#0000FF"/> <size android:height="50dp" /> </shape> 问题是,如何使这条线垂直? 是的,有一些解决方法,比如绘制一个1px厚的矩形形状,但是如果它包含多个<item>元素,则会使可绘制的XML变得复杂。 任何人有这个机会吗? UPDATE 案件尚未解决。 但是,对于Android文档讨论中的任何人,您可能会发现这很有用: 缺lessAndroid XML手册 UPDATE 除了我标记为正确的那个之外,我没有发现别的办法。 它虽然感觉有点“沉重”,但是如果你碰巧知道答案不要忘了分享;)

标准的Android菜单图标,例如刷新

Android SDK通过android.R.drawable.X提供标准菜单图标。 但是,某些标准图标(如ic_menu_refresh (刷新图标))从android.R中丢失。 有没有什么办法可以从应用程序中提取原始图标? 我已经检查过Android源代码,但是对于图片来说,看起来有点太大了。 我知道Android Drawables网站,但我想获得正确的hdpi , mdpi和ldpi版本,最好是原来的。