0

怎么了伙计们!这是我的布局 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 vidget 上做到这一点。我试过这个

  widgetView.setInt(R.id.conf_RLayoutMultiSize,"setLayoutParams",150+widgetBodySize); 

但这并不成功

4

1 回答 1

0

你可以这样做:

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
于 2014-03-24T23:09:00.367 回答