如何删除单选按钮的空白区域

时间:2018-03-09 06:53:12

标签: android xml android-layout

我想删除单选按钮右侧的那些空格,因为您可以看到我附加的屏幕截图 - > in Layout Inspecter

我以编程方式添加了带有

选项的radiobuttons
RadioButton.setClickable(false),
RadioButton.setButtonDrawable(R.drawable.input)

进入带有参数的Linearlayout 选项

params.weight = 1,
params.gravitiy = Gravity.CENTER,
params.setMargins(4,0,4,0),

在xml in XML中使用此params是可行的,但如果我以编程方式添加单选按钮则无效

这是布局检查器中的Radiobutton属性

fg_ null
getEllipsize()  null
getFilterTouchesWhenObscured()  false
getFitsSystemWindows()  false
getScrollBarStyle() INSIDE_OVERLAY
getTag()    null
getTransitionName() null
getVisibility() VISIBLE
isActivated()   false
isChecked() false
isClickable()   false
isEnabled() true
isFocusableInTouchMode()    false
isHapticFeedbackEnabled()   true
isHovered() false
isInTouchMode() true
isPressed() false
isSelected()    false
isSoundEffectsEnabled() true
mID NO_ID
mPrivateFlags   0x1008830
mPrivateFlags_DRAWN 0x20
mSystemUiVisibility 0x0
mSystemUiVisibility_SYSTEM_UI_FLAG_VISIBLE  0x0
mViewFlags  0x18000001
getContentDescription() null
getImportantForAccessibility()  yes
getLabelFor()   -1
getAlpha()  1.0
getElevation()  0.0
getPivotX() 154.0
getPivotY() 102.0
getRotation()   0.0
getRotationX()  0.0
getRotationY()  0.0
getScaleX() 1.0
getScaleY() 1.0
getSolidColor() 0
getTransitionAlpha()    1.0
getTranslationX()   0.0
getTranslationY()   0.0
getTranslationZ()   0.0
getX()  320.0
getY()  0.0
getZ()  0.0
hasOverlappingRendering()   true
hasShadow() false
isDrawingCacheEnabled() false
isHardwareAccelerated() true
isOpaque()  false
mLayerType  NONE
willNotCacheDrawing()   false
willNotDraw()   false
hasFocus()  false
isFocusable()   true
isFocused() false
getBaseline()   120
getHeight() 204
getLayoutDirection()    RESOLVED_DIRECTION_LTR
getLocationOnScreen_x() 408
getLocationOnScreen_y() 602
getRawLayoutDirection() INHERIT
getWidth()  308
hasTransientState() false
isLayoutRtl()   false
layout_bottomMargin 0
layout_endMargin    -2147483648
layout_gravity  CENTER
layout_height   WRAP_CONTENT
layout_leftMargin   4
layout_mMarginFlags 0x00
layout_rightMargin  4
layout_startMargin  -2147483648
layout_topMargin    0
layout_weight   1.0
layout_width    WRAP_CONTENT
mBottom 204
mLeft   320
mRight  628
mTop    0
getMeasuredHeightAndState() 204
getMeasuredWidthAndState()  308
mMeasuredHeight 204
mMeasuredWidth  308
mMinHeight  0
mMinWidth   0
mPaddingBottom  0
mPaddingLeft    0
mPaddingRight   0
mPaddingTop 0
mUserPaddingBottom  0
mUserPaddingEnd -2147483648
mUserPaddingLeft    0
mUserPaddingRight   0
mUserPaddingStart   -2147483648
mScrollX    0
mScrollY    0
getRawTextAlignment()   GRAVITY
getRawTextDirection()   INHERIT
getScaledTextSize() 14.117646
getSelectionEnd()   -1
getSelectionStart() -1
getTextAlignment()  GRAVITY
getTextDirection()  FIRST_STRONG
getTextSize()   48.0
getTypefaceStyle()  NORMAL
mCurTextColor   -16777216
mGravity    17
mText   
android:style/Theme.DeviceDefault.Light.DarkActionBar() forced
    forced

有人帮助我吗?

1 个答案:

答案 0 :(得分:0)

对于谁需要帮助,只需使用此方法

RadioButton.setCompoundDrawablesWithIntrinsicBounds(null, ResourcesCompat.getDrawable(getResources(), R.drawable.image_name,null),null,null);

它删除了它的左边填充