如何制作无文字的RadioButon?

问题描述

我只想要一个没有文本的简单RadioBttun,我做了下面的代码,但是我得到的是一个单选按钮小部件,其空间很小,我认为是保留给文本的。那么如何摆脱这个空间呢?

<RadioButton
    android:id="@+id/rb_topup_item_account_selection_status"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@null" />

enter image description here

解决方法

通过覆盖以下内容,将最小尺寸设置为零:


public class PlayerInfo : MonoBehaviour
{
    // move
    public Rigidbody2D playerRb;
    public float xSpeed = 10f;
    private Vector2 xForce;

    // Jump
    public float jumpForce;

    // Ground Check
    private bool isGrounded;
    public Transform groundCheck;
    public float checkRadius;
    public LayerMask whatIsGround;

    // Animator
    public Animator animator;

    // Start Timer
    public Text countDownStart;
    private float countDown = 4f;
    private bool moveBool = false;

    // Start is called before the first frame update
    void Start()
    {
        playerRb = GetComponent<Rigidbody2D>();
        animator.enabled = false;
    }

    void Update()
    {
        if (countDown <= 0f)
        {
            countDownStart.enabled = false;
            moveBool = true;
        }
        countDown -= Time.deltaTime;
        countDownStart.text = Math.Floor(countDown).ToString();        
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        isGrounded = Physics2D.OverlapCircle(groundCheck.position,checkRadius,whatIsGround);

        xForce = new Vector2(xSpeed * Time.deltaTime,0);

        //playerRb.AddForce(xForce);
        if (moveBool)
        {
            playerRb.velocity = xForce.normalized * xSpeed;
            animator.enabled = true;
        }

        if (CrossPlatformInputManager.GetButtonDown("Jump"))
        {
            jump();
        }

        if (Input.GetKey(KeyCode.A))
        {
            jump();
        }
    }

    public void slide()
    {
        if (isGrounded == true)
        {
            animator.SetBool("isSliding",true);
        }
        else
        {
            animator.SetBool("isSliding",false);
        }
    }

    public void jump()
    {
        if (isGrounded == true)
        {
            playerRb.AddForce(new Vector2(0f,jumpForce),ForceMode2D.Impulse); // Impulsa eğrisine göre.   
            animator.SetBool("isJumping",true);
        }
        else
        {
            animator.SetBool("isJumping",false);
        }
    }

    private void OnDrawGizmosSelected()
    {
        Gizmos.DrawWireSphere(groundCheck.position,checkRadius);
    }
}

此外,请确保您未在​​XML中包括/somepath - for countries /:countryName - for states /:stateName - for cities. 属性

,

只需将以下属性添加到 XML 布局中的 RadioButton 元素即可。它将删除默认填充。

android:minWidth="0dp"
android:minHeight="0dp"

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...