android-custom-view

Recyclerview: listen to padding click events

只愿长相守 提交于 2019-12-23 06:59:21
问题 I have an horizontal RecyclerView with leftPadding = 48dp , topPadding = 24dp and clipToPadding = false . It starts with an empty space on the left, but when the user scrolls the list its items are drawn on that (previously empty) space. The top space is always empty. This RecyclerView is inside a FrameLayout with foreground = selectableItemBackground . My problem comes from the fact that the RecyclerView consumes and ignores touches on the left and top spaces, meaning an OnClickListener won

Making a randomly moving clickable button on Android

丶灬走出姿态 提交于 2019-12-23 05:50:37
问题 I'm looking to create randomly moving clickable buttons in Android (for a childrens game). I followed the code on this website to create some randomly moving circles around the screen http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/ with the Animated words view changed to this: public class AnimatedWordsView extends ImageView { private Context myContext; int [] xCoOrd = {-1, -2, -3, -4, -5, -6, -7, -8}; int [] yCoOrd = {-1, -2, -3, -4, -5, -6, -7, -8};

Error inflating class from library

牧云@^-^@ 提交于 2019-12-23 05:15:06
问题 I got a problem with a class I'm using from an external library. the "futuresimple/android-floating-action-button"-library to be exact. I combined it with nineoldandroids to be able to use it in Android SDK-Versions prior to 14. It seems to work (library gets built with gradle without problems). Now my problem is, that I can't initiate a FloatingActionMenu. LogCat says: Process: com.packagename, PID: 1531 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename/com

Scroll/Panning or drag in custom layout

我与影子孤独终老i 提交于 2019-12-23 05:11:31
问题 I have made custom Relative Layout for Zooming with lot of research since I am new to Android and now I want to incorporate the panning/dragging which should behave like Imageview, that is, bound limits. I am not using a matrix but the ScaleGestureDetector.SimpleOnScaleGestureListener . Now I want to incorporate the panning/dragging in the same. How do I achieve drag/panning in my code? Here is my custom relative layout with proper commenting and understanding. /* ////////////////////////////

Android onDraw doesn't draw anything in custom TextView when setting singleLine to true

我们两清 提交于 2019-12-23 02:01:46
问题 There is a bug when I set singleLine to true in the XML layout of my custom TextView in my project. I don't know how to fix it. Is there anyone who can help me? github link 回答1: Finally, I used android:maxLines="1" instead. 来源: https://stackoverflow.com/questions/33828761/android-ondraw-doesnt-draw-anything-in-custom-textview-when-setting-singleline

how to to create custom & composite view in android

谁说我不能喝 提交于 2019-12-22 18:34:33
问题 I would like to create a custom and composite view in android. My custom view will include 1 textview, 5 radiobuttons two buttons and some images. I don't know how to do it. if there would be some example or code spinet, it would be nice.. 回答1: I think it could help you: First you can define a RelativeLayout in xml, with all the elements you want on it, placed like you want. Second, when you have that layout defined, you can develop a custom class, extending RelativeLayout, and inflate that

Children of extended LinearLayout defined in XML do not show

六眼飞鱼酱① 提交于 2019-12-22 10:43:07
问题 In my project I have screens where the same pattern is repeated a lot - it's basically a container for views consisting of a linear layout with the heading, image and specific background. To avoid copying and pasting the same sequence multiple times I thought I could create a compound view, extend LinearLayout and define all the "styling" there, and then just use that component in my layouts. I followed howto's and examples and got my compound view to work. However, all examples I've seen use

Search Edit Text like Google Play

落花浮王杯 提交于 2019-12-22 06:59:54
问题 How to implement Search Edit text like Google play with Back and Cancel button on Right at place of Voice search and suggestions list should display below the complete edit text layout. 回答1: This is SearchView with some customization check the docs http://developer.android.com/guide/topics/search/search-dialog.html Actvity declared like this <activity android:name=".SearchableActivity" android:launchMode="singleTop" > <intent-filter> <action android:name="android.intent.action.SEARCH" /> <

Bug with Android 4.3 ImageView method getImageMatrix()

旧城冷巷雨未停 提交于 2019-12-22 05:15:08
问题 I recently upgraded to Android 4.4 and someone of the features of my app have surprisingly stopped working. I have this code for initializing and then drawing my custom view. The basic idea is it adjusts the zoom level so the entire view fits on the screen. private void initAtZoomLevel(float zoomLevel){ .... Matrix transformMatrix = new Matrix(); transformMatrix.setScale(initialZoomLevel, initialZoomLevel); float yTransCenter = (screenHeight - mapHeight)/2.0f; setImageMatrix(transformMatrix);

Custom a CheckedTextView in android

放肆的年华 提交于 2019-12-22 00:56:16
问题 I'm using a code that is not mine in my work. This code uses CheckedTextView, do this: ... AlertDialog.Builder alert; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); switch (soundPreference.getType()) { case BOOLEAN: CheckedTextView checkedTextView = (CheckedTextView) v; boolean checked = !checkedTextView.isChecked(); ((CheckedTextView) v).setChecked(checked); switch (soundPreference.getKey()) { case SOUND_ACTIVE: sound.setAlarmActive(checked); break; ... works perfectly, the