I have two LinearLayout in which there are several textView, the first field has a certain size. Is it possible to fill the first field by filling in the textView in the second field?
UPD: Based on the proposed option, implemented this method:
public void changeParent(TextView tv){ FrameLayout flCoverBook = findViewById(R.id.flCoverBook); LinearLayout llTextView1 = findViewById(R.id.llTextView1); if (llTextView1.getHeight() <= flCoverBook.getHeight()) { ((LinearLayout) tv.getParent()).removeView(tv); ((LinearLayout) findViewById(R.id.llTextView1)).addView(tv); contentFrameLayout.invalidate(); } } But when used, it didn’t work so well, since after adding a textView to the field (layout), the field size remained the same, tried to update it with different methods:
llTextView1.removeAllViews(); llTextView1.requestLayout(); llTextView1.invalidate(); contentFrameLayout.invalidate()l; lTextView1.refreshDrawableState(); Even resorted to quite specific:
lTextView1.setVisibility(View.GONE); lTextView1.setVisibility(View.VISIBLE); lTextView1.removeAllViews(); lTextView1.refreshDrawableState(); etc.
One real solution found the option of getting the size of the field, then with each added textView add its size (height). But this approach does not take into account the number of lines occupied by the textView and this is basically a crutch than a real implementation.
The fields are filled by callback and the screen is updated by the method:
contentFrameLayout.invalidate(); After all these manipulations, I got the impression that you can work with elements on the screen only after its filling and visualization, and not at the time of filling.