【问题标题】:Android Studio TextView format one String centerAndroid Studio TextView 格式一字符串中心
【发布时间】:2019-03-11 09:54:32
【问题描述】:

您好,我有两个字符串和一个 TextView:

TextView test = (TextView) findViewById(R.id.eins);
String one = "DynamicText";
String two = "Title";
test.setText(two+one);

现在我想在 one TextView 中设置两个字符串,但我喜欢将字符串两个文本对齐到中心,字符串一个正常(左)。这怎么可能?

【问题讨论】:

标签: android format


【解决方案1】:
TextView txtOne = (TextView) findViewById(R.id.txtOne );
TextView txtTwo = (TextView) findViewById(R.id.txtOne);
textOne.setText("DynamicText");
txtTwo.setText("Title");
txtTwo.setGravity(Gravity.CENTER);

【讨论】:

    猜你喜欢
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    相关资源
    最近更新 更多