android-custom-view

FAB (floating action button) doesn't float

随声附和 提交于 2019-12-10 04:10:22
问题 I've tried to use the floatingactionbutton element but it doesn't float in UI layout, the floating button occupies part of the layout and isn't over the component, in my case is a viewpager, button doesn't float this is my layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="com

Android Custom View doesn't handle transparency/alpha the right way

荒凉一梦 提交于 2019-12-10 03:21:21
问题 I'm drawing a custom view. In this view I use two different paint and path objects to paint to the canvas. I'm basically drawing two shapes that overlap. After I add alpha, the part of the view that is overlapped is darker than the rest of the image. This is undesired, but I'm not sure how to fix it. This is a clipping of my code to show how I'm using alpha in my NewButtonView.java Paint paint = new Paint(); int color = 0x33ffffff; int borderColor = 0xFF000000; paint.setColor(color); paint

Bound a View to drag inside RelativeLayout

ⅰ亾dé卋堺 提交于 2019-12-09 15:44:57
问题 I have created a draggable view inside RelativeLayout . But it seems to go beyond the RelativeLayout. I simply want to make a View draggable inside ViewGroup And this view is draggable according to Screen. And it is draggable beyond the boundaries of RelativeLayout. How could I restrict it to stay draggable within RelativeLayout. CustomImageButton public class ImageButtonCustom extends ImageButton implements View.OnTouchListener{ float dX, dY; private RelativeLayout rootView; private

Android: Drawing an arc inside a circle

本秂侑毒 提交于 2019-12-09 12:53:58
问题 I'm trying to draw an arc inside a circle to represent the temperature, but I'm having a difficult time achieving that. During my search I found those solutions This one I couldn't understand what is the scale method for, and is drawing more than one arch, which confused me a bit This post gave it a fixed size where I need the size to be controlled by the custom view in my XML layout From here I understood the concept the degrees but I didn't understand how to determine the oval size What i

How to add draggable icon with navigation drawer

强颜欢笑 提交于 2019-12-09 12:24:26
问题 My problem: I want to add draggable icon in navigation drawer. This icon combined with listview of navigation drawer when drawer open. see similar like this, What I have tried, I searched in StackOverflow like similar question this, Draggable drawer with a handle (instead of action bar) on top of other apps But all answer suggest to 3rd party library. My question 1.It`s possible to add draggable icon with navigation drawer? 回答1: For drag layout there is github library which is useful for it

Using canvas and bitmap in Android , how to get this image?

微笑、不失礼 提交于 2019-12-09 10:38:02
问题 I am new in android. I am trying to draw this image(match statistic) and fill the image with color with 10% to 100% . I tried this much and this is image this is the code public class DrawView extends View { Paint paint = new Paint(); public DrawView(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { paint.setColor(Color.BLACK); paint.setStrokeWidth(3); canvas.drawRect(30, 30, 100, 100, paint); paint.setStrokeWidth(0); paint.setColor(Color.GRAY); canvas

Get the total count of number of rows in the Custom Listview Android

喜夏-厌秋 提交于 2019-12-09 08:04:19
I am trying to getting the total Count of the getView custom listview. But want to display in the different layout. Here is my onCreatedView. I am not sure how to inflate the layout. Thanks for all your help. private static ListView addDropListView = null; private TransactionAddDropAdapter addDropAdapter = null; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragmentPendingTrades = inflater.inflate(R.layout.fragment_transactions_pending, container, false); pendingTradesView = inflater; return fragmentPendingTrades; } public void

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

て烟熏妆下的殇ゞ 提交于 2019-12-09 07:35:26
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 fantouch Finally, I used android:maxLines="1" instead. 来源: https://stackoverflow.com/questions/33828761/android-ondraw-doesnt-draw-anything-in-custom-textview-when-setting-singleline

Draw Bitmap in Custom ImageView and get the Co-ordinates of the ImageView irrespective of the device

拈花ヽ惹草 提交于 2019-12-09 06:21:53
问题 I want to get the co-ordinates of the ImageView , Irrespective of device size. Is there any possible way !! I have tried to create specific size for the ImageView ,Even specific size for the Parent View also ,but its not working. I have tried the following possible ways. int[] posXY = new int[2]; imageview.getLocationOnScreen(posXY); int MoveX = posXY[0]; int MoveY = posXY[1]; I have tried with Matrix too ,But not working. Matrix m = imageview.getImageMatrix(); Tried the below code, but it is

Invalidate doesn't cause OnDraw

空扰寡人 提交于 2019-12-09 04:11:32
I have problem with my Android app. I've created custom view ( http://syedwasihaider.github.io/blog/2015/07/12/XamarinViews/ up to step 2), overriden onDraw and I draw black screen and text "Draw {i}" where i is number that increments every time onDraw occurs. I want to call this method 30 times/second (or 60), so I've set up timer that causes Invalidate() every 33 ms. But Invalidate() doesn't cause onDraw at all! (It's not like its a delay between invalidate and ondraw, ondraw isn't called at all). I've tried to set SetWillNotDraw(false) , but it didn't work. Here's my code: class DrawCanvas