Results 1 to 2 of 2
  1. #1
    beans is offline Member
    Join Date
    Mar 2016
    Posts
    1
    Rep Power
    0

    Default how do you set position of view on relativelayout

    hi i have a number of seekbars that i want to display to the right of each other
    i have my relative layout and perameters
    Java Code:
     rl=new RelativeLayout(this);
            RelativeLayout.LayoutParams screenRules = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);//W,H
            rl.setLayoutParams(screenRules);
            rl.addView(tv);
            setContentView(rl);
    and elsewher in code after adding these bars and ids to an ArrayList<wrapperclass> i try add them to layout
    Java Code:
            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.MATCH_PARENT);//w,h
            p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    
            for(int i=0;i<bars.size();i++){//loop through arraylist and add seekbars to layout
                if(i==0) {//if its the first just allign bottom
                    View v=bars.get(i).rsb;
                    v.setLayoutParams(p);
                    rl.addView(v);//add to view
                }else{
                    View v=bars.get(i).rsb;
                    p.addRule(RelativeLayout.ALIGN_RIGHT, bars.get(i - 1).rviewId);//this should add rule to align right of previous bar but instaed dumps them ontop
                    v.setLayoutParams(p);
                    rl.addView(v);
                }
    
    
            }
    but they all allign bottom but get placed on top of each other
    any ideas?

  2. #2
    NZelian is offline Member
    Join Date
    Mar 2016
    Posts
    6
    Rep Power
    0

    Default Re: how do you set position of view on relativelayout

    Why don't you use a LinearLayout with a horizontal orientation which would align to the bottom of the parent, and would contain the SeekBars. Like so:

    how do you set position of view on relativelayout-12.png

    You will probably have to put that LinearLayout in a HorizontalScrollView (Are your SeekBars small enough to fit inside the width of your device, after having been laid out next to each other horizontally?).
    __________________________________________________

    EDIT:

    Couldn't you also use a bottom ToolBar there, which could contain the SeekBars (though I haven't seen apps with many seekbars side by side, and I am not sure what the purpose of your SeekBars is).

    how do you set position of view on relativelayout-layout_structure_toolbars7.png

    By the way I am not an expert, so perhaps you should wait for answers by others as well.
    Last edited by NZelian; 03-12-2016 at 05:25 PM.

Similar Threads

  1. Replies: 1
    Last Post: 11-15-2011, 11:21 PM
  2. Replies: 0
    Last Post: 05-13-2011, 07:38 PM
  3. How enter this mode-gui/design-view/code-view
    By lse123 in forum NetBeans
    Replies: 0
    Last Post: 02-28-2010, 09:09 PM
  4. get position in string from caret position
    By helloworld111 in forum AWT / Swing
    Replies: 5
    Last Post: 02-19-2009, 01:36 AM
  5. Updating a view using actions in a seperate view
    By xcallmejudasx in forum Eclipse
    Replies: 0
    Last Post: 10-24-2008, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •