添加自定义的ImageView主版面 [英] Adding a Custom ImageView to main layout

查看:190
本文介绍了添加自定义的ImageView主版面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是这笔交易。

我一直在寻找在这个code左右延伸的ImageView的:

i was looking over this code about extending an ImageView:

http://marakana.com/forums/android/examples/98.html

和我不知道我怎样才能在新视图添加到现有的XML布局文件,与其他一些意见一起。

and i was wondering how can i add the new View to an existing xml layout file, along with some other views.

我已经这样做我的主线性布局内:

already i did this inside my main linear layout:

<FrameLayout android:id="@+id/FrameLayout01" android:layout_width="300dp" android:layout_height="300dp">
        <com.marakana.Rose android:layout_height="wrap_content" android:layout_width="wrap_content"/>

,但问题是,这种方法的onDraw方法不被调用。

but the problem is that this way the onDraw method doesn't get called.

任何人都可以提出一个解决方案?也许一些例子,你用XML布局相结合CustomViews。

can anyone suggest a solution for this? maybe some examples where you combine CustomViews with xml layout.

TNX。

推荐答案

我想我解决了它。我用我的code在main.xml中的文件和它的作品。我不得不做的事情是覆盖新类的构造函数接受AttributesSet一起与上下文作为参数,然后使用findViewById(CustomViewName)引用它的活动,并使用在CustomView定义的函数。

I think I solved it. I used my code in the main.xml file and it works. the thing I had to do was to override a new class constructor accepting AttributesSet alongside with the context as a parameter and then use findViewById(CustomViewName) to reference it in the activity and use the functions defined in the CustomView.

这篇关于添加自定义的ImageView主版面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆