2012-02-16 3 views
0

LinearLayoutandroid:layout_height = "fill_parent"의 세로가 있습니다.수직 선형 레이아웃에 비례하여 자식 뷰를 배포하십시오.

이제 데이터베이스의 특정 매개 변수를 기반으로 동적으로 여러 개의 자식 뷰를 추가하고, 다른 뷰에서는 3 개의 뷰를 동적으로 추가합니다.

이 동적으로 추가 된 하위 뷰를 수직 계열 LinearLayout에 어떻게 배포하여 균일하게 배포 할 수 있는지 알고 싶습니다. I 수평 ScrollViewLinearLayout을 포함해야하고, 수평 ScrollView 내부 GridView를 사용하는 것이 매우 실망 같이

BTW 난 GridView를 사용할 수 없다.

편집 : 추가 소스 및 XML 파일 :

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/serverScreensScreen1LL1" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#FFFFFF" > 

<ScrollView 
     android:id="@+id/serverScreensScreen1SV1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" 
     > 

    <HorizontalScrollView 
     android:id="@+id/serverScreensScreen1HSV1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" 
     > 

     <LinearLayout 
      android:orientation="horizontal" 
      android:id="@+id/serverScreensScreen1LL2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

     </LinearLayout> 
    </HorizontalScrollView> 
</ScrollView> 
</LinearLayout> <!-- Main Container --> 

자료 제공 :

private void drawContent() 
{ 
    LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(fpfp); 

    LinearLayout.LayoutParams lp3 = new LinearLayout.LayoutParams(wcwc); 
    lp3.weight = 0.3F; 

    LinearLayout ll1 = (LinearLayout) findViewById(R.id.serverScreensScreen1LL2); 

    for (int i=0; i<20; i++) 
    { 
      LinearLayout ll2 = new LinearLayout(this); 
      ll2.setOrientation(LinearLayout.VERTICAL); 
      ll2.setLayoutParams(new   LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,  LinearLayout.LayoutParams.FILL_PARENT)); 
      ll2.setWeightSum(1.0F); 

       LinearLayout ll3 = new LinearLayout(this); 
       ll3.setOrientation(LinearLayout.VERTICAL); 
       ll3.setLayoutParams(lp3); 
        TextView tv1 = new TextView(mContext); 
        tv1.setText("Sample Text A: " + i); 
        tv1.setBackgroundColor(Color.rgb(12, 34, 56 + i * 8)); 
        tv1.setLayoutParams(wcwc); 
       ll3.addView(tv1); 


       LinearLayout ll4 = new LinearLayout(this); 
       ll4.setOrientation(LinearLayout.VERTICAL); 
       ll4.setLayoutParams(lp3); 
        TextView tv2 = new TextView(mContext); 
        tv2.setText("Sample Text B: " + i); 
        tv2.setBackgroundColor(Color.rgb(34, 12 + i * 8, 56)); 
        tv2.setLayoutParams(wcwc); 
       ll4.addView(tv2); 

       LinearLayout ll5 = new LinearLayout(this); 
       ll5.setOrientation(LinearLayout.VERTICAL); 
       ll5.setLayoutParams(lp3);    
        TextView tv3 = new TextView(mContext); 
        tv3.setText("Sample Text C: " + i); 
        tv3.setBackgroundColor(Color.rgb(56 + i * 8, 34, 12)); 
        tv3.setLayoutParams(wcwc); 
       ll5.addView(tv3); 

      ll2.addView(ll3); 
      ll2.addView(ll4); 
      ll2.addView(ll5); 

     ll1.addView(ll2); 
    } 
} 

어떤 제안을 plz ...

+0

각 어린이에 대해 안드로이드 : layout_weight = "1" – Booger

+0

, 이미 시도 : ( –

+0

) Nitin Bansal, 한 번 시도해보십시오 layout_weight - 그것이 필요한 것입니다 – Silver

답변

0

난 당신이를 배포하려는 방법의 확실하지 않다 조회수를 늘릴 수 있지만 가중치로 시도해 볼 수 있습니다.

의 워드 프로세서 내에서 android:weightSum을 검색하십시오.

+0

소스 파일로 내 질문을 업데이트했습니다. 뭔가 빠졌는지 확인해주세요 ... thnx in advance ... –

+0

@NitinBansal : 시도하고있는 이미지를 그릴 수 있습니까? 달성하기 위해?'HorizontalScrollView' 내부에'ScrollView'를 갖는 것이 좋지 않습니다. – Macarse

+0

@ 확신 ... 여기에 내가 원하는 부가 가치세의 그림이 있습니다 : http://twitpic.com/8kor38 .... btw, i scrollview 내부에 모든 행을 필요로 할 때를 고려하여 avaiable보다 더 눈에 보이는 영역을 차지합니다. 더 나은 대안, 알려 주시기 바랍니다. 심지어이 일을하는 것에 찬성하지 않는 Im –

관련 문제