垂直的我已经会写了,现在要写水平的。我把xml中的属性设置成了水平的,然后就只显示了第一个元素。我想把剩下的元素水平显示出来
估计你要设置一个HorizontalScrollView吧,
http://blog.csdn.net/fuxuanyang/article/details/52444232
官方:
https://developer.android.google.cn/reference/android/widget/HorizontalScrollView.html
你把你写的代码贴出来,看看哪里写的不对
for (int i = 0; i < TOTAL_COUNT; i++) {
TextView textView = new TextView(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
DisplayUtils.dip2px(30));
textView.setLayoutParams(lp);
textView.setGravity(Gravity.CENTER);
textView.setText(datas[i] + "次");
linearLayout.addView(textView);
}