android-drawable

Programmatically set custom drawables for radio buttons

核能气质少年 提交于 2019-12-07 16:28:42
问题 I'm developing a basic paint application in android and I can't seem to programmatically set custom drawables for my radio buttons. These radio buttons consist of a LayerDrawable with a white ColorDrawable for the borders and an inset yellow (or whatever color it is) ColorDrawable for the center. I put this LayerDrawable along with another one (it has black borders to indicate selection) in a StateListDrawable to preserve the RadioButton functionality. But when I try setButtonDrawable

Android: Rounded Corners TextView XML Layout with custom Header

空扰寡人 提交于 2019-12-07 16:16:59
问题 I would like to create a custom XML layout for my TextView, using rounded corners and a custom header, such as this example. I found this very useful link that creates the following quite similar result. <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Bottom 2dp Shadow --> <item> <shape android:shape="rectangle"> <solid android:color="#d8d8d8" /> <corners android:radius="7dp" /> </shape> </item> <!-- White Top color --> <item

OneSignal-Pushnotification small icon not displayed on Android

半世苍凉 提交于 2019-12-07 15:04:27
问题 We have a Cordova-App which contains a file 'icon.png' in every drawable-xy folder. We provide push notifications using OneSignal. The notifications are working as expected. Except the small icon. There is only a blank icon on the top bar of my phone, where app-symbols are displayed. I tried using the following snippet: { ... "small_icon" : "@android:drawable/icon.png" .... } I also tried lots and lots of other variations without "android", without "drawable", without slash, with .png and

Color overlay on drawable Android

寵の児 提交于 2019-12-07 12:31:55
问题 I've been following this tutorial here Medium - Diagonal Cut View to get that diagonal view effect <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/colorPrimary" /> <item> <bitmap android:src="@drawable/bebe" android:gravity="center" android:alpha="0.1" /> </item> <item android:top="260dp" android:bottom="-100dp" android:left="0dp" android:right="-260dp"> <rotate android:fromDegrees="-10" android

How to create android drawable consisting of two colors side by side?

亡梦爱人 提交于 2019-12-07 10:54:28
问题 Uisng XML is it possible to create a drawable where half of it would be color1 and another half would be color2? When I set that drawable as a background of a view it should look like in the image below. 回答1: Doing it by xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:right="100dp"> <shape android:shape="rectangle"> <size android:height="100dp" android:width="100dp"/> <solid android:color="@android:color/black"/

setColorFilter doesn't seem to work on kitkat

房东的猫 提交于 2019-12-07 08:40:28
问题 I'm attempting to colorize a graphic using setColorFilter . The following code seems to work fine on lollipop, but it seems to have no effect on kitkat, the icon is rendered in it's original colors: Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_chat_button).mutate(); icon.setColorFilter(context.getResources().getColor(R.color.control_tint_color), PorterDuff.Mode.SRC_ATOP); icon.invalidateSelf(); The mutate and invalidateSelf calls don't seem to have any effect on the

How to have badge icon at corner of a layout

萝らか妹 提交于 2019-12-07 03:06:08
问题 I wanted to have a badge at corner of a layout . I managed to get badge inside the layout but not able to achieve at corner of it . Currently my code gives me : What i want : i want to have this badge to over right top corner of an layout . I want something like this : Toolbar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas

How to have an image with a dynamic text in it, all in a drawable, like the “today” action item on Google Calendar app?

早过忘川 提交于 2019-12-06 19:59:42
问题 Background Google Calendar app has an action item that dynamically change according to the current day ("today"): I'm required to do a very similar thing, but with a slightly different image that surrounds the text. The problem I did succeed to make it work, by creating a Drawable that has text and image in it (based on here). However, I'm don't think I did it well enough : Text font might be different across devices, so might not fit well in what I wrote. Not sure if it's because of the

VectorDrawable image becomes pixelated

倾然丶 夕夏残阳落幕 提交于 2019-12-06 17:51:30
问题 I've used a couple of images which I've imported using Android Studio's Vector Asset Studio through a local SVG file. The images loaded perfectly on my nexus 6p, however, on the Sony Xperia Z, its very pixelated, and on Samsung Galaxy s2, its even worse. From my understanding, since the file is a xml (vector) and not a png file, it should have been able to resize automatically or am I missing out on something. I've attached an image of the 3 cases. EDIT: Just some extra info: The file was

Android: How to clear an EditText by cross Button in the right side

守給你的承諾、 提交于 2019-12-06 17:28:57
问题 I have created an EditText for search, which contains on the left side a search icon and on the right side of icon: <EditText android:id="@+id/Search" android:layout_width="250dp" android:layout_height="wrap_content" android:drawableLeft="@android:drawable/ic_menu_search" android:drawableRight="@android:drawable/ic_delete" android:hint="Search Product .." > </EditText> I want to know how can I clear the content of EditText when I click the cross button. Thank you in advance. 回答1: An improved