简体   繁体   中英

2 seekbars on eachother (android)

In my application I have 2 seekbars. The error is that they are on each other! I just cant put them 2 next to each other across all the width of the screen! They are alignd to the left! I want one aligned to th left, one to the right!

The code is:

public View wrapLabelAndSeekbar(String labelText, int width)
{
    RelativeLayout layout = new RelativeLayout(this);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(250, 250);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // Doesn't work

    seekerWidth = new SeekBar(this);
    seekerHeight = new SeekBar(this);
    seekerWidth.setProgress(Main.seekerPlaceWidth);
    seekerHeight.setProgress(Main.seekerPlacHeight);

    layout.addView(seekerHeight, params);
    layout.addView(seekerWidth, params);

    return layout;
}

I can only change their size up to half the screen. No more.

What can I do?

与往常一样,这是一个小错误...显然...我只是将屏幕的宽度一分为二,所以所有屏幕都位于同一位置...

     RelativeLayout ll = new RelativeLayout(this);
     ll.setId(99);

       seekerWidth = new SeekBar(this);
       seekerHeight = new SeekBar(this);
       seekerWidth.setProgress(Main.seekerPlaceWidth);
       seekerHeight.setProgress(Main.seekerPlacHeight);

       seekerWidth.setId(1);
       seekerHeight.setId(2);

      RelativeLayout.LayoutParams lay = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

 lay.addRule(RelativeLayout.ALIGN_PARENT_TOP);
 ll.addView(seekerWidth, lay);

    RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    p.addRule(RelativeLayout.BELOW, seekerWidth.getId());
    ll.addView(seekerHeight, p);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM