custom-view

Error in creation of custom view

为君一笑 提交于 2019-12-04 11:39:19
i have customview, i want to add that in the xml file i tried like this but i am getting this error Custom view TouchImageView is not using the 2- or 3-argument View constructors; XML attributes will not work this is the xml i am using.. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <view class="com.zoom.TouchImageView" android:id="@+id/webView1" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> Shailendra Singh Rajawat Add

How are you supposed to use a ShapeDrawable with a PathShape to draw a line on a custom View?

岁酱吖の 提交于 2019-12-03 16:09:09
I am attempting to draw a line in a custom View . Here I've created a simple Path with just a single segment, created a PathShape from that, and finally stuck that into a ShapeDrawable with the intention of using that to draw on the Canvas inside onDraw() . However, this does not work. See my example, here. package com.example.test; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.PathShape; import

Styling Custom Views

风流意气都作罢 提交于 2019-12-03 09:45:40
问题 I have a few custom views in my Android project and I've added the relevant details to the attrs.xml file. And now I can implement my objects through XML. This works fine. How do I style these elements? When I try to use my custom attributes in the styles.xml is get an error "No resource found that matches the given name:" For using the custom views in normal xml developement I use xmlns:app="http://schemas.android.com/apk/res/bla.bla.bla". What is the correct for use in styles? This is what

Custom Notification View

China☆狼群 提交于 2019-12-03 08:19:29
问题 I would like to create a notification icon view that looks similar to the Google+ app's notification. The difference will be that I need to be able to change the color at runtime where as the Google+ icons gray or red so I'm assuming they are using a StateListDrawable. What is the best approach for this? I'd prefer to have the rounded clipped corners and have the option to have a drawable inside. This custom view will be placed in the Action Bar as well. I still need the view to respond to

Smaller active area for custom UIBarButtonItem

狂风中的少年 提交于 2019-12-03 07:59:01
I have a UINavigationBar with a custom UIBarButtonItem (which uses a UIButton as its custom view). The problem is: the active area of the custom button is much too large, if I tap at least 40 pixels outside the button, it still gets registered as a tap on the button. This results in accidental taps. How can I reduce the active area on these buttons? I noticed this weirdness too. I found that using a container UIView fixes this. For example: UIButton *menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; [menuButton addTarget:self action:@selector(revealMenu:) forControlEvents

How to get an enum which is created in attrs.xml in code

余生长醉 提交于 2019-12-03 02:53:25
问题 I created a custom View (find it here) with an declare-styleable attribute of type enum. In xml I can now choose one of the enum entries for my custom attribute. Now I want to create an method to set this value programmatically, but I can not access the enum. attr.xml <declare-styleable name="IconView"> <attr name="icon" format="enum"> <enum name="enum_name_one" value="0"/> .... <enum name="enum_name_n" value="666"/> </attr> </declare-styleable> layout.xml <com.xyz.views.IconView android:id="

Styling Custom Views

对着背影说爱祢 提交于 2019-12-03 01:25:08
I have a few custom views in my Android project and I've added the relevant details to the attrs.xml file. And now I can implement my objects through XML. This works fine. How do I style these elements? When I try to use my custom attributes in the styles.xml is get an error "No resource found that matches the given name:" For using the custom views in normal xml developement I use xmlns:app="http://schemas.android.com/apk/res/bla.bla.bla". What is the correct for use in styles? This is what my style looks like currently <style name="Journey_DaySelect_Sunday"> <item name="app:onImage">

Custom Notification View

可紊 提交于 2019-12-02 22:14:21
I would like to create a notification icon view that looks similar to the Google+ app's notification. The difference will be that I need to be able to change the color at runtime where as the Google+ icons gray or red so I'm assuming they are using a StateListDrawable. What is the best approach for this? I'd prefer to have the rounded clipped corners and have the option to have a drawable inside. This custom view will be placed in the Action Bar as well. I still need the view to respond to android:background state list drawables so I can have the click and selected accordance working. This

How to get an enum which is created in attrs.xml in code

∥☆過路亽.° 提交于 2019-12-02 18:18:08
I created a custom View (find it here ) with an declare-styleable attribute of type enum. In xml I can now choose one of the enum entries for my custom attribute. Now I want to create an method to set this value programmatically, but I can not access the enum. attr.xml <declare-styleable name="IconView"> <attr name="icon" format="enum"> <enum name="enum_name_one" value="0"/> .... <enum name="enum_name_n" value="666"/> </attr> </declare-styleable> layout.xml <com.xyz.views.IconView android:id="@+id/heart_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" app:icon=

Custom Checkable View which responds to Selector

雨燕双飞 提交于 2019-12-02 16:18:48
I have a group of FrameLayout which I want to be checkable/selectable, That is, after a click I would like the FrameLayout to display as checked - when pressed again I would like it to become un checked . What's more, I want this visual que to be described as usual through though the use of a <selector> . I can't seem to get this working - I'm not sure what I'm missing: public class CheckableFrameLayout extends FrameLayout implements Checkable { private boolean mChecked = false; public CheckableFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void