答案 0 :(得分:2)
使用垂直方向的线性布局。使用layout_width="match_parent"
和相应的gravity
属性为每行添加文本视图。
https://developer.android.com/reference/android/widget/LinearLayout.html
编辑:
如果你的诗作为弦乐的一个元素,每个元素都是你诗中的一行,你可以这样做:
//Initialise your layout in your activity onCreate()
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout);
layout.setOrientation(LinearLayout.VERTICAL);
//Start listening to your firebase data and put this somewhere in the callback:
// poemLines is a list of Strings you get from firebase
for(i=0; i<poemLines.size(); i++){
TextView view = new TextView(context);
view.setText(poemLines.get(i));
//set any other attributes to your textview that you want, width, height, font, etc
view.setGravity(i%2==0?END:START);
layout.add(view);
}