1
Je souhaite utiliser la même mise en page dans plusieurs formats. Par conséquent, je dois changer la taille.Comment modifier la largeur d'un objet physique dans un appwidget?
Comment puis-je modifier la largeur de RelativeLayout avec l'image picframe par programme?
<?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" />
...
J'ai essayé
remoteView.setString(R.id.picframe, "setWidth", "50dp");
et
remoteView.setString(R.id.picframe, "setLayoutWidth", "50dp");
sans succès.
Merci pour l'indice avec la balise 'merge', mais dans ce cas, c'est nécessaire, car la mise en page est plus complexe que ce que vous pouvez voir dans ce sniplet. – Wookiee