android-custom-view

Overriding View.onSaveInstanceState() and View.onRestoreInstanceState() using View.BaseSavedState?

て烟熏妆下的殇ゞ 提交于 2019-12-18 14:43:13
问题 Assume you want to derive your own View class from an existing View implementation, adding a bit of value, hence maintaining a few variables which represent your View's state in a meaningful way. It would be nice if your View would save its state automatically just like others do (if an ID is assigned) so you would want to override onRestoreInstanceState() and onSaveInstanceState() . Of course, you need to call the respective methods of your base class, and you need to combine your state

Change the behaviour of a GridView to make it scroll horizontally rather than vertically

谁说我不能喝 提交于 2019-12-18 13:32:20
问题 I want to make a UI element like a GridView , I want it's complete functionality but want it to be horizontally scrollable rather than vertically. By horizontal scroll I mean it should be built that way and not put in a HorizontalScrollView . My would be Custom GridView will have fixed number of rows say 4-5 and the columns should be extensible based on number of items in the Adapter . You can think of it as the opposite of what the native GridView does, yet it should maintain the

Real custom shape of button

与世无争的帅哥 提交于 2019-12-18 12:36:07
问题 Given any shape (either filled circle, star, triangle, bitmap with transparent areas, etc.) I would like to know if it's possible (using the latest Android API) to know if the user has clicked on the view, or outside of it. For example, if I have a circular button, I would like to know if the user has clicked inside the circle, but not outside of it. Is it possible? If not, maybe I could poll the pixel of the touch event, and if it's transparent, ignore it, and if it isn't, handle it as a

How to implement Custom listview text animation

情到浓时终转凉″ 提交于 2019-12-18 12:35:30
问题 I am creating shopping application in android. In my app, I show list of items from custom list view. If customer select an item, Selected item text moves from listview into shopping cart image. Like below image, This type of animation is my requirement. But my animated view stopped at end of custom row.. like this image. My animation.xml code, <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear

Cardview corner background not transparent

白昼怎懂夜的黑 提交于 2019-12-18 12:26:42
问题 I have a custom implementation of a CardView support widget but I can't seem to get the background for the corners transparent when I include it in my layout-file. However, if I simply place the CardView support widget in my layout-file it suddenly works. How can I get the corners transparent for my custom component? This is the layout file for my custom implementation of the CardView: view_card.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http

Android - Google Maps inside CircleView

懵懂的女人 提交于 2019-12-18 09:08:57
问题 I wanted to show map inside a circle view where circle's outside area filled with a color. I referred a post Draw transparent circle filled outside. But now the problem is touch events. Map can be touched through outside circle view while I need map can be touched (zoom or move) only form inside Circle view (where the map is visible). What I tried, setEnabled=false clickable=false but still map is touched from outside circle view. Is that possible to achieve that map can be touched from

Draw ARC Polyline in Google Map

会有一股神秘感。 提交于 2019-12-18 05:49:04
问题 How Can I Draw Arc Polyline in Google Map ? I already used this code to create curved Polyline. Here is the method to draw curved Polyline: private void showCurvedPolyline (LatLng p1, LatLng p2, double k) { //Calculate distance and heading between two points double d = SphericalUtil.computeDistanceBetween(p1,p2); double h = SphericalUtil.computeHeading(p1, p2); //Midpoint position LatLng p = SphericalUtil.computeOffset(p1, d*0.5, h); //Apply some mathematics to calculate position of the

Vintage Thermometer component + SensorSimulator on the Android emulator

纵饮孤独 提交于 2019-12-18 05:22:25
问题 After I found this nice custom component that analogly (is this the right word?) displays the temperature read from the Android device's temperature sensor, I wanted to test it with the emulator to see how it works so I've found this Sensor Simulator and altered the component's source to work with it. I did manage it to work on en emulated device, however I've done a few lucky guesses and'd like to know what exactly I've done :-) Here are the changes in thermometer's code I had to make to get

Stop OnLongClickListener from firing while dragging

孤人 提交于 2019-12-18 04:46:12
问题 I have a custom View with bitmaps on it that the user can drag about. I want to make it so when they long click one of them I can pop up a context menu with options such as reset position etc. In the custom View I add my OnLongClickListener: this.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // show context menu.. return true; } }); And override onTouchEvent to look something like this: public boolean onTouchEvent(MotionEvent event) {

Fill Sine Graph Android

泄露秘密 提交于 2019-12-18 03:44:18
问题 I have this code: public class TestView extends View { private Path mPath; private Paint mPaint = new Paint(); public TestView(Context context) { this(context, null); } public TestView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public TestView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mPath = new Path(); mPath.moveTo(0, 0); mPath.quadTo(50, -50, 100, 0); mPath.quadTo(150, 50, 200, 0); mPath.quadTo(250, -50, 300, 0); mPath