android-custom-view

ClickableSpan not clickable in custom view (not TextView)

╄→гoц情女王★ 提交于 2019-12-24 01:18:24
问题 In our app we want to improve scroll speed via drawing custom views with text. Problem is ClickableSpan not clicked. For TextView we can use textView.setMovementMethod(LinkMovementMethod.getInstance()); But what can I do to make link clicking work in custom view? public class AutoLinkTextView extends View { private static final String TAG = "AutoLinkTextView"; private StaticLayout staticLayout; public AutoLinkTextView(Context context) { super(context); initializeViews(); } public

Resize Imageview based on the parent height

↘锁芯ラ 提交于 2019-12-23 20:46:15
问题 I have a layout as defined below <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:orientation="vertical" > <ImageView android:id="@+id/movieImageView" android:layout_width="75dp" android:layout_height="75dp" android:layout_centerVertical="true" android:paddingBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:src="

No preview of custom views on UI designer in Eclipse

梦想的初衷 提交于 2019-12-23 19:22:49
问题 Background I've been creating many types of custom views, and normally i get their previews shown just fine on the UI designer of ADT. lately, after updating to the newest version of the ADT ( 22.0.5.v201307292155--757759 ), i can't see any type of custom view, not even the simplest one . The problem now, i know for sure that custom views can be previewed fine , since if i create a new workspace and create them, i can see them just fine. the problem is that on the current workspace, which has

Callback after all child Views from XML have been added to ViewGroup?

陌路散爱 提交于 2019-12-23 15:12:27
问题 I was writing a custom ViewGroup and came across the following problem: The ViewGroup should be usable by specifying properties in XML only. However, I want to do some internal initialization in code after the ViewGroup has been created and all its child View s from XML have been added (that is, when the layout inflator has added all the child View s of a ViewGroup specified in XML). All I found related to this are recommendations to use getViewTreeObserver().addOnGlobalLayoutListener(...) .

extending android button by using onDraw

孤者浪人 提交于 2019-12-23 13:19:59
问题 I want to change my button shape BUT I WANT TO USE onDaw method and EXTENDING button class. So what I've just done for the beginning is : <view class = "com.example.button.MainActivity$MyButton" android:layout_width="wrap_content" android:layout_height="wrap_content" /> and public static class MyButton extends Button { public MyButton(Context context) { super(context); } public MyButton(Context context, AttributeSet attrs) { super(context, attrs); } public MyButton(Context context,

Why is my android custom view not square?

回眸只為那壹抹淺笑 提交于 2019-12-23 07:40:06
问题 I created a custom view to display a gameboard for a game I'm developing. The gameboard needs to be a square at all times. So with and height should be the same. I followed this tutorial to achieve this. I added the following code to my custom view: @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = getMeasuredWidth(); int height = getMeasuredHeight(); int widthWithoutPadding = width -

how to add views inside a custom View?

青春壹個敷衍的年華 提交于 2019-12-23 07:38:10
问题 I have a class like that, and there are about 10 of them public class DataItemPlainView extends View{ public DataItemPlainView(Context context) { super(context); // TODO Auto-generated constructor stub }} Now I need to put TextView, ImageView etc inside this view. And when I call it from somewhere, I want to get my customView. setting a view to a custom layout is a case too. Thanks 回答1: Your custom view needs to extend ViewGroup or one of the other classes that extends ViewGroup . For example

Does Android studio layout editor shows custom view properties?

孤街醉人 提交于 2019-12-23 07:03:24
问题 I have a compound view which consists of two Buttons and one Text view. I want to edit properties of these child views in the Android Studio Layout Editor but I can't. It only shows basic properties but no properties of my custom view. Does the Android Studio Layout Editor only shows limited number of properties set by default? Is it possible to edit properties of my custom view from there, without manually editing the XML files? Thanks in advance!! 回答1: As described in http://developer

How to add image to the canvas so that I can draw line on it

无人久伴 提交于 2019-12-23 07:02:15
问题 I have the code for custom view but unable understand how to set image so that I can draw on the image.I have tried solutions given on stackoverflow, but image is not getting added can anyone help me with this, Kindly check the code given below: Or how do I set Image as background for my customview.I am getting only the white background. public class CustomView extends View { private static final String LOG_CAT = CustomView.class.getSimpleName(); //drawing path private Path drawPath; /

How to add image to the canvas so that I can draw line on it

半城伤御伤魂 提交于 2019-12-23 07:02:01
问题 I have the code for custom view but unable understand how to set image so that I can draw on the image.I have tried solutions given on stackoverflow, but image is not getting added can anyone help me with this, Kindly check the code given below: Or how do I set Image as background for my customview.I am getting only the white background. public class CustomView extends View { private static final String LOG_CAT = CustomView.class.getSimpleName(); //drawing path private Path drawPath; /