动态创建 TextView 时,第二个 TextView 没有出现

When creating TextView dynamically the second TextView is not appearing

我正在使用下面的代码在我的 LinearLayout 中创建两个 TextView。当按下屏幕的这个指定区域时,我以这种方式使用它们来捕捉触摸事件

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    LinearLayout layOut = (LinearLayout)findViewById(R.id.loginView);

    LinearLayout.LayoutParams loginParams = new LinearLayout.LayoutParams(520, 70);
    loginParams.setMargins(120, 670, 0, 0);
    TextView loginBttn = new TextView(this);
    layOut.addView(loginBttn);
    loginBttn.setBackgroundColor(Color.GREEN);
    loginBttn.setLayoutParams(loginParams);
    loginBttn.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            // Code touch events
        }
    });

    LinearLayout.LayoutParams forgotParams = new LinearLayout.LayoutParams(370, 40);
    forgotParams.setMargins(150, 770, 0, 0);
    TextView forgotBttn = new TextView(this);
    layOut.addView(forgotBttn);
    forgotBttn.setBackgroundColor(Color.GREEN);        
    forgotBttn.setLayoutParams(forgotParams);
    forgotBttn.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            // Code touch events
        }
    });

我正在使用 Green 来定位它们。完成后,我将删除这些行。第一个工作正常,但第二个没有出现,我不明白为什么。

我认为它在屏幕外尝试较低的保证金和位置值 例如:

    LinearLayout.LayoutParams loginParams = new LinearLayout.LayoutParams(50, 50);
    loginParams.setMargins(10, 10, 0, 0);
    TextView loginBttn = new TextView(this);
    layOut.addView(loginBttn);
    loginBttn.setBackgroundColor(Color.GREEN);
    loginBttn.setLayoutParams(loginParams);


    LinearLayout.LayoutParams forgotParams = new LinearLayout.LayoutParams(10, 10);
    forgotParams.setMargins(20, 20, 0, 0);
    TextView forgotBttn = new TextView(this);
    layOut.addView(forgotBttn);
    forgotBttn.setBackgroundColor(Color.GREEN);        
    forgotBttn.setLayoutParams(forgotParams);