Android 线性布局';s子视图根据设备更改行';s宽度问题

Android 线性布局';s子视图根据设备更改行';s宽度问题,android,android-layout,android-linearlayout,textview,Android,Android Layout,Android Linearlayout,Textview,嗨,朋友们,我正在使用线性布局和方向水平以编程方式填充文本视图的 代码: LinearLayout linearLayout = (LinearLayout)findViewById(R.id.layout1); for (int i = 0; i < 20; i++) { TextView textView = new TextView(this); textView.setText("Hello " + i); linearLayout.addView(text

嗨,朋友们,我正在使用
线性布局
方向
水平
以编程方式填充
文本视图的

代码:

LinearLayout linearLayout = (LinearLayout)findViewById(R.id.layout1);
for (int i = 0; i < 20; i++) {
    TextView textView = new TextView(this);
    textView.setText("Hello " + i);
    linearLayout.addView(textView, i);
}
LinearLayout LinearLayout=(LinearLayout)findViewById(R.id.layout1);
对于(int i=0;i<20;i++){
TextView TextView=新的TextView(此);
setText(“你好”+i);
linearLayout.addView(textView,i);
}
现在,我在屏幕上看到了非常奇怪的表情:

我想要这种类型的视图:


LinearLayout
内的视图应根据设备宽度更改其行。任何人有任何想法可以实现这一点,请提供帮助。

使用setNumColumns()将文本视图添加到网格布局

根据我的说法,你必须在GridLayoutManager中使用RecyclerView。@ChintanBawa你能分享任何链接或示例吗。你达到你的要求了吗?这应该作为一个理由,或者如果需要的话给出适当的解释和代码。