Enhacements for homescreen widgets (layout variants, centering)

corwin42

Expert
Licensed User
Longtime User
I don't know if Erel has this already on his "wished features list" so I will post it here again:

1. Support of layout variants for homescreen widgets. Currently only the first layout variant in the layout file is converted to an xml file. Would be great if B4A will generate all variants and put the xml files in the corresponding directories.

2. Support for centering widgets in their containers. Currently B4A uses only AbsoluteLayouts for generating the widget layout. The problem with that is that different resolutions have different container sizes for widgets so if you center your widget for one resolution it is not centered for other resolutions. You can center the widget with modifying the layout file and surround the AbsoluteLayout with two LinearLayouts. I use this layout for my widgets (maybe that it can be done simpler but this works quite well for me):

B4X:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/ws5_base1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:layout_x="0dp" android:layout_y="0dp">
<LinearLayout android:id="@+id/ws5_base2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" android:layout_gravity="center_vertical">
  <AbsoluteLayout android:id="@+id/widget4x1_pmain" android:layout_width="310dp" android:layout_height="90dp" android:layout_x="0dp" android:layout_y="0dp" android:layout_gravity="center_horizontal" android:visibility="visible" android:background="@drawable/widget4x1_pmain_background">
[...Normal widget Views here...]
  </AbsoluteLayout>
</LinearLayout>
</LinearLayout>
</AbsoluteLayout>
 

corwin42

Expert
Licensed User
Longtime User
Sorry, that I push this old thread up.

The centering works well in current B4A versions.

Is there any chance if the layout variants for homescreen widgets will make it into the next version? At least support for a different landscape layout would be really great.
 
Top