问题描述
我只想要一个没有文本的简单RadioBttun,我做了下面的代码,但是我得到的是一个单选按钮小部件,其空间很小,我认为是保留给文本的。那么如何摆脱这个空间呢?
<RadioButton
android:id="@+id/rb_topup_item_account_selection_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@null" />
解决方法
通过覆盖以下内容,将最小尺寸设置为零:
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"