Milos Cuculovic
Milos Cuculovic

Reputation: 20223

How to get all the RelativeLayout parametres from a View

I have a ImageView in my relative layout. How can I get all the parametres of this ImageView: not the x and y but I need all the parametres from this view: like CenterHorizontal = true etc...

Upvotes: 1

Views: 2430

Answers (2)

Vivek Khandelwal
Vivek Khandelwal

Reputation: 7849

To get the rules (i.e parameter) use RelativeLayout.LayoutParams. So you need to get the LayoutParams from the View.

To get all rules, use getRules() in RelativeLayout.LayoutParams.

The array of point to RelativeLayout constant by index.

For example:

  • rule RelativeLayout.ALIGN_LEFT contain ID of the View align left
  • rule RelativeLayout.CENTER_HORIZONTAL contain RelativeLayout.TRUE if it is set.

Upvotes: 7

youchy
youchy

Reputation: 427

you can use int[] RelativeLayout.LayoutParams.getRules() defined here http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html#getRules().

Take the rules, parse it and get the value.

Upvotes: 2

Related Questions