There are 2 layouts that I create dynamically (they are in CardView)

LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); //LinearLayout.LayoutParams lparamsFile = new LinearLayout.LayoutParams(150, 150); LinearLayout linearLayoutTextContent = new LinearLayout(ctx); //Контейнер для текста сообщения linearLayoutTextContent.setOrientation(LinearLayout.HORIZONTAL); linearLayoutTextContent.setLayoutParams(lparams); LinearLayout linearLayoutFileContent = new LinearLayout(ctx);//Контейнер для вложения linearLayoutFileContent.setOrientation(LinearLayout.HORIZONTAL); linearLayoutFileContent.setLayoutParams(lparams); 

How do I make linearLayoutFileContent under linearLayoutTextContent

    1 answer 1

     LinearLayout mainLayout = new LinearLayout(ctx); //Главный Layout linearLayoutTextContent.setOrientation(LinearLayout.VERTICAL); linearLayoutTextContent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); mainLayout.addView(linearLayoutTextContent); mainLayout.addView(linearLayoutFileContent); 
    • Yes, only 2 layouts overlap each other, and I need one to be under the other - Heaven
    • @Heaven in the sense of another? For example, do you want 2 LinearLayout 1 in the top Layout to LinearLayout on top of another below? those. so that after 1, go 2 layout ? - Iman
    • That's right, only when adding linearLayoutTextContent.addView (linearLayoutTextContent); they overlap each other - Heaven
    • @Heaven Well, then you need to add them to the main Layout , if you create all the markup programmatically, then create another 1 Layout , which will be the main one and add linearLayoutTextContent first, and then linearLayoutFileContent , and as you said it will the other - Iman