How to get button component's width?

i am making an extension . but i don't know how to get the button's width.
i just only want to get the button's width using@simpleFunction.

please help me

Use Button.getWidth();

1 Like

can you please clarify that this will work or not.

private int value

@Simplefunction
 public Object Label(Component component) {
 this.value = label.width();
 }

This should be capital.

This should be AndroidViewComponent


If you want to use @Techno_Vedang method u need to use this method:
button.getView()
Then use the View u got to get the width.

1 Like

and about label

It will work for every component.

this will work to get the width of label ?

private int value

@Simplefunction
 public Object Label(androidviewcomponent component) {
 this.value = label.Width();
 }

As it's defined to return an Object you need to return something.Else, set its return type to void

private int value

@Simplefunction
public void Label(androidviewcomponent component) {
this.value = label.Width();
}

now this will work ??

It will work or not @MohamedTamer

Should be capital letters
it should be AndroidViewComponent
And it would work( i expect you want to save your width in a variable and the use it some where else ?

2 Likes
@SimpleFunction(description = "blah blah blah")
public String GetWidth(AndroidViewComponent component){
   String a = component.Width().toString();
   return a;
}

do it like this

2 Likes

thanks @MohamedTamer and @Techno_Vedang

2 Likes

one more question , how can i return the id of the label

You mean the name of the component, for example :label1 ?

1 Like

no, i mean the id of component . when you create a dynamic component you need to type a id.
i am telling about that

is it possible to get the id ??

please help

Please answer

The id used with dynamic components are self created using Hashtable which is similar to dictionaries.It's not a native one :wink:

and how can i get the button name(not ID).