【发布时间】:2017-01-25 18:03:34
【问题描述】:
在相对布局内的 xml 文件中,我采用了 textview。我在 java 文件中提供了文本、字体大小、文本颜色。但我仍然无法获得字幕文本。我该怎么做。 在此先感谢
MainActivity.java 文件
public class MarqueeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_marquee);
// got the data from another activity
String str = getIntent().getStringExtra("Text");
float fontSize = getIntent().getFloatExtra("FontSize", 64.0f);
int textColor = Color.alpha(getIntent().getIntExtra("TextColor",0xff0000ff));
int bgColor = Color.alpha(getIntent().getIntExtra("BGCOLOR",0xff0000ff));
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.activity_marquee);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
// created text view
TextView marqueeText = new TextView(this);
marqueeText.setText(str);
marqueeText.setTextSize(fontSize);
marqueeText.setTextColor(Color.alpha(textColor));
marqueeText.setBackgroundColor(Color.alpha(bgColor));
marqueeText.setTypeface(Typeface.MONOSPACE,Typeface.BOLD);
marqueeText.setSelected(true);
marqueeText.setSingleLine(true);
marqueeText.setMarqueeRepeatLimit(-1);
marqueeText.setHorizontallyScrolling(true);
relativeLayout.addView(marqueeText,params);
}
}
请更正上述代码以获取字幕文本
【问题讨论】:
标签: android flashlight