Friday 15 May 2015

How to make titled border for RadioGroup in Android? -


As a title - is it possible to create a headline border around the radio group? Or at least one simple border ... Thanks

The limit titled, I do not know ... you may want to add a TextView widget just above the threshold, but a plain border, has told how here I have a border around the radio group: here is my original radio group (three buttons, horizontal)

  Android: Radio: Group: android: id = "@ + id / myRadioLayout" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Andro E: layout_marginTop = "38dp" android: orientation = "horizontal" android: height = "24dp" & gt; & Lt; RadioButton Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: id = "@ + id / radioBtn1" android: text = "RadioButtonl" Android: checked = "true" style = "@ android: style / widget. Combat Button. Radiabutan "Android: Textism =" 14sp "& gt; & Lt; / RadioButton & gt; & Lt; RadioButton Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: id = "@ + id / radioBtn2" android: text = "RadioButton2" style = "@ android: style / Widget.CompoundButton.RadioButton" Android: textSize = "14sp" & gt; & Lt; / RadioButton & gt; & Lt; RadioButton Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: id = "@ + id / radioBtn3" android: text = "RadioButton3" Android: checked = "true" style = "@ android: style / widget. Combat Button. Radiabutan "Android: Textism =" 14sp "& gt; & Lt; / RadioButton & gt; & Lt; / RadioGroup & gt;   

So, if I want a boundary around my radio button group, then I will add an XML file to my drawable folder. Let's call it "border.xml" Here's the code for the border. Xml:

  & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Size xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Shape = "Rectangle" & gt; & Lt; Stroke Android: width = "5px" Android: color = "# 000000" /> & Lt; / Size & gt;   

After that, you add the following code to your radio group XML:

  & lt; Android: layout_marginTop = "38dp" Android: Orientation = "Horizontal" Android: background = "@ drawable / border": RadioGroup Android: id = "@ + id / myRadioLayout" Android: layout_width = "match_parent" android: layout_height = "wrap_content" Android: Height = "24dp" & gt;   

And a border should appear around your radio group. Note that you can get different sizes to vary the properties range, gradients, corners, etc. round possible characteristics of elements, can be found here:

< / Div>

No comments:

Post a Comment