getLeft() not working for TextView in android -
I have a custom control (button) is built in Android which left image and center the text and right arrow image. When using this custom control I have to pull the upper limit and lower limit for this button.
& lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/ Android" Android: Leaut_vidth = "Mac_perent" Android: Leaut_heit = "Mac_perent" android: background = "@ color / white" android: orientation = "Vertical" & gt; & Lt; View Android: id = "@ + ID / VivPlline" style = "@ style / BSF_withline" /> & Lt; RelativeLayout android: id = "@ + id / lytcontrollayout" Android: layout_width = "fill_parent" Android: PaddingLeft = "L2dp" Android: PaddingRight = "L2dp" Android: layout_height = "38dip" Android: layout_margin = "5dip" & gt; & Lt; imageView android: id = "@ + id / imgrightimage" Android: layout_width = "25dip" Android: layout_height = "25dip" Android: layout_centerVertical = "true" / & gt; & Lt; Android: layout_height = "wrap_content" android: paddingLeft = "5dp" Android: layout_centerVertical = "true" Android: layout_toRightOf = "@ + ID / imgritimage": Android: layout_width = "wrap_content" android: id = "@ + id / txttextoncontrol" "Android: Textaces =" 17sp "Android: TextColver =" @color / gray "& gt; & Lt; / TextView & gt; & Lt; imageView android: id = "@ + id / imgarrow" Android: layout_width = "20dip" Android: layout_height = "20dip" Android: layout_alignParentRight = "true" Android: layout_centerVertical = "true" android: src = "@ drawable / Bisfaroromait" & Gt; & Lt; / ImageView & gt; & Lt; / RelativeLayout & gt; & Lt; View Android: id = "@ + ID / Videoteline" style = "@ style / bsf_viwline" />
If I am using only one button, it will show the absolute upper limit and lower limit. Otherwise the bottom border should be drawn in alignment with textview. I created the scene for the boundaries I took getLeft () for the TextView. And if the lower limit should be reduced I set marginleft to see as the following:
Public Zero AddMarginToLowerBorder () {int margin = _text.getLeft (); LinearLayout.LayoutParams Parameters = (LinearLayout.LayoutParams) _viewlower.getLayoutParams (); Params.setMargins (margin, 0, 0, 0); _viewlower.setLayoutParams (parameter); }
but getLeft () is not working.
If I set this way,
LinearLayout.LayoutParams parameter = (LinearLayout.LayoutParams) _viewlower.getLayoutParams (); Parameters.Set margin (70, 0, 0, 0); _viewlower.setLayoutParams (parameter);
, so it's working properly.
Please help me.
Before using your view, use getLeft () (and getTop and so on) can not do. Instead of manually calculating the margin, keep your boundaries in a relative layout and android: layout_below
/ android: layout_above
/ android: layout_toRightOf.
Use properties.
Comments
Post a Comment