android - Scroll view with Button, ImageView and viedoView -


i try make scroll view button, imageview , viedoview.

i create dynamically code.

when put button video, can see both of them. same button , imageview.

my problem when there videview , imageview. when have both of them cant see vidoview , seeo imageview.

thank helping :)

here code:

xml scrollview code:

  <scrollview     android:layout_width="match_parent"     android:layout_height="fill_parent"     android:fillviewport="true" >         <relativelayout            android:layout_width="fill_parent"            android:layout_height="fill_parent" >      <linearlayout         android:id="@+id/datemain"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="vertical" >      </linearlayout>      </relativelayout>     </scrollview> 

my java code:

  private void addpics() {              extras = getintent().getextras();             string s = extras.getstring("date");              databasemain data = new databasemain(this);             data.open();             paths = data.getworkoutpic(s);             data.close();              if(paths == null || paths.length < 1)             return;              layoutparams lp = new layoutparams(layoutparams.wrap_content, layoutparams.match_parent);              for(int = 0; < paths.length; i++){                  bitmap yourselectedimage = bitmapfactory.decodefile(paths[i]);                 imagebutton pic = new imagebutton(this);                 pic.setimagebitmap(yourselectedimage);                 pic.setadjustviewbounds(true);                 pic.setlayoutparams(lp);                 pic.setid(i);                 pic.setonlongclicklistener(new onlongclicklistener() {                     public boolean onlongclick(view arg0) {                                      selectedpictrue = arg0.getid();                         onbuttonclickevent(arg0);                         return true;                        }                 });             linear.addview(pic);             }              }          private void addvideos() {              extras = getintent().getextras();             string s = extras.getstring("date");              databasemain data = new databasemain(this);             data.open();             videos = data.getworkoutvideo(s);             data.close();              if(videos == null || videos.length < 1)             return;              linearlayout linear = (linearlayout) findviewbyid(r.id.datemain);             layoutparams lp = new layoutparams(layoutparams.wrap_content, layoutparams.match_parent);             layoutparams lp2 = new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content);              for(int = 0; < videos.length; i++){                  button b = new button(this);                 b.setlayoutparams(lp2);                 b.settext("delete video");                 b.setid(i+50);                 linear.addview(b);                 b.setonclicklistener(this);                  videoview video = new videoview(this);                 video.setvideopath(videos[i]);                 video.setlayoutparams(lp);                 video.setid(i+50);                 video.setmediacontroller(new mediacontroller(this));                 video.bringtofront();                    linear.addview(video);             }                    }          public void setlogview(string date){           databasemain database = new databasemain(this);         database.open();         = database.daylog(date);         database.close();          if (all == null ||  all[0].length < 1 || all[3][0] == null || all[3][0].equals(""))             return;          layoutparams lp = new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content);          (int = 0; < all[0].length; i++){             string temporay = "";              for(int j = 0; j < all.length; j++)                 {                        temporay = temporay + " " + all[j][i];                 }              button mine = new button(this);             mine.settext(temporay);             mine.settextcolor(getresources().getcolor(r.color.black));             mine.setbackgroundcolor(color.transparent);             mine.setlayoutparams(lp);             mine.setid(i);             mine.setonclicklistener(this);             linear.addview(mine);             //toast.maketext(this, ""+i, toast.length_short).show();         }     }            

it's because have of layoutparams' heights layoutparams.match_parent. "match_parent" means want height of element big parent container. not sure you're trying accomplish layout wise, can't recommend fix other first trying set width wrap_content , taking there.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -