Параметры RelativeLayout для виджета главного экрана
Как дела, парни! Вот пример моего макета XML:
<RelativeLayout
android:id="@+id/conf_RLayoutMultiSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
>
<ImageView
android:id="@+id/widget_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/transparent100" />
<ImageView
android:id="@+id/widget_scar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/scar1" />
</RelativeLayout>
<ImageView
android:id="@+id/widget_dial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/dial1" />
</RelativeLayout>
Вопрос - возможно ли изменить размер conf_RLayoutMultiSize через код? У меня есть макет cofigurantion, где я сделал это легко, но не могу понять, как это сделать на виджете manescreen. Я пробовал это
widgetView.setInt(R.id.conf_RLayoutMultiSize,"setLayoutParams",150+widgetBodySize);
но это не было успешным
1 ответ
Вы можете сделать это следующим образом:
RelativeLayout rlay = (RelativeLayout) findViewById(R.id.conf_RLayoutMultiSize);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(value_width, value_height); // Set whatever parameters you want here
rlay.setLayoutParams(params); // Assign parameters to relative layout