android - Adding Views to LinearLayout with weight programmatically -


I am getting stucked on the following problem: The answer and the percentage of people answered the specific question. Therefore, I want to add the "bar" to my app which displays the percentage. I try to solve this by using the scenes in a linear layout and weighting it.

I want to add different answer programs, this is the code that I have so far received. My problems are, that I am not getting close to weighting ideas and resizing them.

  / * Add all questions * / Relative layout my_root = (Relative layout) findViewById (R.id.ownerRL); / * Add a new linerlayout as a container for the question * / LinearLayout A = New LinearLayout (this); A.setOrientation (LinearLayout.HORIZONTAL); My_root.addView (A); / * Create a new view in this container for the status bar * / view new_view = new (getBaseContext ()); New_view.setBackgroundColor (Color.YELLOW); LinearLayout.LayoutParams lp = New LinearLayout.LayoutParams (50, 20, 3); Relative layout. Layout Parameters = (Relative Layout. LayoutParam) et LayoutParam (); Params.addRule (relative layout. Below, R.id.question1); A.addView (new_view); New_view2 = View new (getBaseContext ()); New_view.setBackgroundColor (Color.GREEN); ViewGroup.LayoutParams lp2 = New ViewGroup.LayoutParams (50, 20); Relative layout. Layout Parameters 2 = (Relational Layout. Layout Parm) ET Layout Param (); Params2.addRule (relative layout., Below, R.D. Questian 1); Params2.addRule (RelativeLayout.LEFT_OF, new_view.getId ()); A.addView (new_view2);   

The green view should actually be one of the yellow (which is not visible).

How is it managed such that it creates a red / white bar whose height is 4px and red and weight are weighted?

Thank you for your help!

check link, linear layout load it like this

  LinearLayout.LayoutParams param = new LinearLayout.LayoutParams (Layout Paramount. MATCH_PARENT, Layout Paramount. MATCH_PARENT, 1.0f);   

The weight of the last parameter is. Get this help.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -