android-drawable

selectableItemBackground as item in layer-list

不打扰是莪最后的温柔 提交于 2019-12-04 09:57:02
问题 I've copied a file from the Google IO Schedule app source (https://github.com/google/iosched) namely selected_navdrawer_item_background.xml <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/backgroundColor"> <shape> <solid android:color="#12000000" /> </shape> </item> <item android:drawable="?android:selectableItemBackground"/> </layer-list> I want to use this to highlight the currently selected item in a NavigationDrawer. My problem is, when I

Create animation by changing image in ImageView with Timer (or Handler)

我的未来我决定 提交于 2019-12-04 08:09:55
I want to create an simple animation by changing frames inside an ImageView. I don't want to use AnimationDrawable because i need to receive events when a frame changed or when the animation stoped, to be able to play it backwards, restart it and so on. My problem is that the frames doesn't actually change event though setImageDrawable gets called (on the main thread). So everythings seems to work fine excepts that the frames doesn't change (actually just a frame is drawn, the first one). So my code: public class AnimatedImageView extends ImageView implements Animatable, Runnable { private

Integer array of resource ids returns 0

六月ゝ 毕业季﹏ 提交于 2019-12-04 07:26:30
I have a set of resource ids stored in an array. This is accessed inside the recycler view to populate an image view. The problem is when I access the array, all values returned is 0. // arrays.xml <array name="array_category_icons"> <item>@drawable/autumn</item> <item>@drawable/backpack</item> </array> // inside recycler view adapter int[] myIcons = getActivity().getResources().getIntArray(R.array.array_category_icons); myIcons[i] always returns 0. The drawables are in the hdpi folder only. Do this: TypedArray ta = getResources().obtainTypedArray(R.array.array_category_icons); Drawable[]

Android - Drawable repeat shape to create pattern

谁说胖子不能爱 提交于 2019-12-04 03:20:22
问题 I need to create a pattern to set as a background of some View . I want the pattern to look something like this: I don't want to import any image to drawable, but instead, I want to create my own shapes, layer-list and the ultimate goal is to have a pattern as a background. Is is possible to achieve this without having to import any external image? 回答1: You can get a pattern of repeating tiles based upon shape drawables by creating a custom View and overriding onDraw() . Let's start by

How to create youtube's double-tap gesture on Android?

我怕爱的太早我们不能终老 提交于 2019-12-03 21:37:05
I have application with exoplayer on Android. I have create youtube's double-tap gesture to jump 10 seconds forward or backward with animation! How create this semicircle with ripple effect on double tap? Like this How to do this? I've also wanted to implement such feature, so I wrote it myself to "copy" YouTube's behavior. It's almost the same. You can find the library here including a sample app: https://github.com/vkay94/DoubleTapPlayerView The instructions are written in the README, but due to Stackoverflow principals: 0) Requirements: Minimum SDK: 21 (could be lower, but I've not tested

Why getDrawable() doesn't work on some Android devices?

[亡魂溺海] 提交于 2019-12-03 16:11:04
问题 I am getting "nosuchmethod error" on some user's phones (eg. Motorola Razr i) but it works fine on my HTC. Below is the code. Drawable rBlack; rBlack = getResources().getDrawable(R.drawable.rblack, getTheme()); And the Stacktrace: java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable at org.petero.droidfish.myClass.onCreate(myClass.java:434) at android.app.Activity.performCreate(Activity.java:5248) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)

How to set image from Url using AsyncTask?

为君一笑 提交于 2019-12-03 13:46:45
问题 I'm a newbie programmer an I'm making an android program that displays an image on ImageView from a given url. My problem is how do you use this on the AsyncTask? These codes work on min SDK 2.2 but I switched to min SDK 3.0 so it needs to run on the AsyncTask. Thank you for your help! :) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); satellite(); //satellite's image from main menu } //******satellite url

Custom Android switch track 'animation'

会有一股神秘感。 提交于 2019-12-03 13:13:00
I've created a basic custom Switch , as defined below. <Switch android:id="@+id/availSwitch" android:layout_width="wrap_content" android:switchMinWidth="110dp" android:layout_height="wrap_content" android:track="@drawable/switch_track" android:thumb="@drawable/thumb"/> The @drawable/thumb is a simple PNG which works fine. The @drawable/switch_track is defined below. @drawable/trackon and @drawable/trackoff are PNG's. <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="false" android:drawable="@drawable/trackoff" /> <item android:state_checked=

Inset drawable not working as described in documentation

耗尽温柔 提交于 2019-12-03 12:12:26
As described on Android Developer site: A drawable defined in XML that insets another drawable by a specified distance. This is useful when a View needs a background that is smaller than the View's actual bounds. http://developer.android.com/guide/topics/resources/drawable-resource.html#Inset Instead of just moving the background and leaving the content in place in my case the inset is also moving the TextView. This is the layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout

Android L is ignoring shapes as drawable background

青春壹個敷衍的年華 提交于 2019-12-03 11:08:51
I'm testing Android L Preview on my Nexus 5. I've got problem with my app. I've got some TextViews with background set: android:background="@drawable/rounded_textview" And "rounded_textview" is just shape. It is working great below <=API19. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="3dp"> <solid android:color="#999999"/> <corners android:bottomRightRadius="2dp" android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" android:topRightRadius="2dp"/> </shape> On Android L Developer Preview