在按钮中携带短信,而不在Android中显示
我不想使用任何额外的变量来将我的数据用Button setText
传递给Button本身。我希望按钮上的文字不应该是可见的,或者应该是清晰的,但应该使按钮可见。
P.S:我已经为按钮或正在使用的视图设置了setTag,因此无法使用它。
我在iOS App开发中看到,可以为按钮或视图设置标题,并将其颜色设置为清除,以便无法看到内容。
到目前为止我所尝试的是:
square.setText("-1");
square.setTextSize(0);
square.setTextColor(Color.TRANSPARENT);
square.setTextColor(R.drawable.trans);
这里:“-1”是根据程序逻辑将更改为0 & 1
的数据,但这些数据对用户不应该是可见的,我使用getText()函数来使用这些数据。
(我不想将此按钮设置为不可见或消失,因为此按钮是可点击的)
提前谢谢你!
答案 0 :(得分:1)
将透明度设置为按钮的文字颜色,就像这样,文字将不再可见
<Button android:layout_height="40dp"
android:layout_width="120dp"
android:text="Invisible button"
android:textColor="#00000000"/>
答案 1 :(得分:0)
这样做..
<Button
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:textColor="@android:color/transparent"
android:background="@android:color/transparent" />