-1
я реализованный макет статический в Android макеты папки XML-файл, который выглядит следующим образомДобавление ниже код макета динамически в андроиде активности
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<LinearLayout
android:weightSum="1.0"
android:layout_weight=".75"
android:layout_height="match_parent"
android:layout_width="0dip"
android:background="#ffef1128"
>
<Button
android:id="@+id/textbox12"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:layout_width="0dip"
android:textSize="14sp"
android:text="20%"
android:background="@color/fund_background_blue"
android:textColor="@color/gen_text_color"
/>
</LinearLayout>
<LinearLayout
android:layout_weight=".25"
android:layout_height="match_parent"
android:layout_width="0dip"
>
<TextView
android:id="@+id/TextView22"
android:text="12.4"
android:layout_weight=".15"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:textColor="#000000"
android:gravity="right"
android:layout_gravity="center_vertical" />
<ImageView
android:src="@drawable/ic_up"
android:layout_height="15dp"
android:layout_width="0dip"
android:layout_weight=".05"
android:layout_gravity="center_vertical" />
</LinearLayout>
</TableRow>
Как я могу добавить их в деятельности программна вместо XML Layout.as его включает вес макета и сумму веса. Выход
образец для справки
LinearLayout linLayout1 = новый LinearLayout (это); LinearLayout.LayoutParams linLayoutParams1 = новый LinearLayout.LayoutParams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); linLayoutParams1.weight = 0.75f; // добавление суммы веса для линейного макета1 linLayout1.setWeightSum (1.0f); linLayout1.setBackgroundColor (Color.RED); linLayout1.setGravity (Gravity.CENTER_VERTICAL); linLayout1.setLayoutParams (linLayoutParams1); Bro На самом деле я пробовал что-то вроде общего кода, но получал выход пустым – NaveenThally