To get to the top of each other in my Java code, I find it hard to get two text views. Which I am using:
/ ** is called when activity is created first * / @ Override Crate (bundled saved instainstate) {super. Contents (Saved Instantstate); Layout = New Relative Layout (this); Lesson 1 = new text view (this); Text1.setText ("1"); Text2 = new text view (this); Text2.setText ("2"); RelativeLayout.LayoutParamsP = New Relative Layout LayoutParam (see group layoutperms.wrap_CONTENT, see grouping layoutParamusWRAP_CONTENT); Relative layout. Layout Ports q = New Relative Layout LayoutParam (View Group Layout Parmes. WRAP_CONTENT, View Group. LayoutParmsWRAP_CONTENT); Q.addRule (relative layout. Below, layout.getId ()); Text1.setLayoutParams (Q); Layout.addView (text1); P.addRule (RelativeLayout.BELOW, text1.getId ()); Text2.setLayoutParams (P); Layout.addView (text2); SetContentView (layout); } It stacks two text views on the same line, but I want to show TextView text2 down to TextView text1, so in my app I will call the following as output I want to reveal:
1 2 I have tried all kinds of things with the "addRule" method, I'm not sure Why is not working. I want to know how to do this without XML because I am planning to build a library of those methods which can easily create an adjustable layout by editing an array.
your TextViews id (by default ID - 1 ) ... keep it in the beginning of their initialization: text1.setId (1111); // 1111 is just an example, text2.setId (2222); // Just make sure ID is unique
Comments
Post a Comment