2014-03-24 126 views
0

這是怎麼回事! 這裏是我的佈局XML的例子: 主屏幕小部件的RelativeLayout參數

<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); 

,但它不是成功的

回答

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 
+0

是的,我知道這一點。我想要更改manescreen小部件上的佈局大小。 – user2698308

+0

主屏幕小部件 – user2698308