Android 如何更改appwidget中布局对象的宽度?

Android 如何更改appwidget中布局对象的宽度?,android,android-layout,android-appwidget,Android,Android Layout,Android Appwidget,我想在几种格式中使用相同的布局。因此,我必须改变尺寸 如何以编程方式更改id为picframe的RelativeLayout的宽度 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_frame" android:layout_w

我想在几种格式中使用相同的布局。因此,我必须改变尺寸

如何以编程方式更改id为picframe的RelativeLayout的宽度

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/item_frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="3dp"
        android:paddingRight="3dp"
        android:gravity="left"
        android:layout_centerVertical="true">

    <RelativeLayout
            android:id="@+id/picframe"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_gravity="center"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="10dp" >

        <ImageView
                android:id="@+id/picture"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:scaleType="fitCenter"
                android:layout_centerInParent="true"
                android:adjustViewBounds="true"
                android:contentDescription="@string/app_name" />

        <ImageView
                android:id="@+id/overlay"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:scaleType="fitCenter"
                android:layout_centerInParent="true"
                android:adjustViewBounds="true"
                android:contentDescription="@string/app_name" />
...


没有成功。

我不会尝试。我会将顶层视图设置为一个
而不是一个相对布局,并将其合并为一个具有所需宽度的相对布局。

我不会尝试。我会将顶层视图设置为一个
而不是一个相对布局,并将其合并为一个具有所需宽度的相对布局。

感谢带有“merge”标记的提示,但在本例中,它是必需的,因为布局比您在这个小剪刀中看到的更复杂。感谢带有“merge”标记的提示,但在本例中,它是必需的,因为它的布局比你在这个剪子上看到的要复杂得多。
remoteView.setString(R.id.picframe, "setWidth", "50dp");
remoteView.setString(R.id.picframe, "setLayoutWidth", "50dp");