LinearLayout
과 android:layout_height = "fill_parent"
의 세로가 있습니다.수직 선형 레이아웃에 비례하여 자식 뷰를 배포하십시오.
이제 데이터베이스의 특정 매개 변수를 기반으로 동적으로 여러 개의 자식 뷰를 추가하고, 다른 뷰에서는 3 개의 뷰를 동적으로 추가합니다.
이 동적으로 추가 된 하위 뷰를 수직 계열 LinearLayout
에 어떻게 배포하여 균일하게 배포 할 수 있는지 알고 싶습니다. I 수평 ScrollView
이 LinearLayout
을 포함해야하고, 수평 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 ...
각 어린이에 대해 안드로이드 : layout_weight = "1" – Booger
, 이미 시도 : ( –
) Nitin Bansal, 한 번 시도해보십시오 layout_weight - 그것이 필요한 것입니다 – Silver