Android的设置高度和宽度自定义视图编程 [英] Android set height and width of Custom view programmatically

查看:108
本文介绍了Android的设置高度和宽度自定义视图编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个名为自定义视图 Graphview 。下面是结构为GraphView类

I have created a custom view named Graphview . Here is the structure for the GraphView class.

public class GraphView extends View {

    public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean type) {
        super(context);
                ........
   }

   ..................
   .................
}

我添加使用 addview在tablerow的视图()。这是工作的罚款。现在,我想设置的高度和宽度为 GraphView 。那怎么办?

I have added the view in a tablerow using addview(). It is working fine. Now I want to set height and width for the GraphView. How to do that?

推荐答案

您需要重写 onMeasure()方法,看的android文档和你的SDK目录中的 LABELVIEW 样本学习如何做到这一点。

You need to override the onMeasure() method, look at the android docs and the LabelView sample in your SDK directory to learn how to do it.

这篇关于Android的设置高度和宽度自定义视图编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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