jeudi 7 mai 2015

ScrollView goes out of view

I'm trying scrollview inside linearlayout , this linearlayout weight is 40% , but while adding more elements in scrollview , linearlayout expands it height not adding scrollbar inside the scrollview , Heres is my code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100"  
 >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="20" 
    android:orientation="vertical"/> 

    <LinearLayout
    android:layout_width="match_parent"
   android:layout_height="wrap_content"   

   android:id="@+id/new_list1"
   android:orientation="vertical"
   android:weightSum="20"
   android:layout_weight="40" 
   ></LinearLayout>

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:id="@+id/list"
   android:orientation="vertical"
   android:layout_weight="40" 
   ></LinearLayout>
</LinearLayout>

MyActivityCode

       LinearLayout OuterList  = (LinearLayout)                   
      findViewById(R.id.list);

    LinearLayout OuterScroll = new LinearLayout(context);
    OuterScroll.setOrientation(LinearLayout.VERTICAL);

   for(int i = 0; i<= 10 ; i++)
   {
      LinearLayout childLayout = new LinearLayout(context);
      LinearLayout.LayoutParams trlpChildOuter = new 
      LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
       LayoutParams.MATCH_PARENT,30f);
      OuterScroll.addView(childLayout,trlpChildOuter)

    }


    ScrollView scroll = new ScrollView(context);        
    LinearLayout.LayoutParams Params = new       
    LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,     
     LayoutParams.MATCH_PARENT,100f);
    scroll.addView(OuterScroll, Params);


    LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT,10
0f);

    OuterList.addView(scroll, rps);

Aucun commentaire:

Enregistrer un commentaire