Problems with FrameLayout
-
25-01-2021 - |
Question
i'm adding programatically 3 textviews into a framelayout that haves a camera view.
The three textviews are writting in the same position, but i want to put each textview bottom to another (using framelayout)
I dont know how to do it, i can't find any examples or info about doing this with framelayout programatically, and also i didnt find the way to do it with setlayoutparams, because that method doesn't have x/y parameters or something like that.
here is the code:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
cv = new CustomCameraView(this.getApplicationContext());
FrameLayout rl = new FrameLayout(this.getApplicationContext());
setContentView(rl);
rl.addView(cv);
tv1=new TextView(getApplicationContext());
tv2=new TextView(getApplicationContext());
tv3=new TextView(getApplicationContext());
rl.addView(tv1);
rl.addView(tv2);
rl.addView(tv3);
tv1.setText("Test1");
tv2.setText("Test2");
tv3.setText("Test3");
}
Solution
Make a linearLayout, add the textViews to this LinearLayout , and add this linearLayout to your FrameLayout. Use the orientation of LinearLayout vertical.
use LinearLayout.setOrientation(LinearLayout.VERTICAL)
, method for setting orientation to vertical.