D ducphu Active Member Licensed User Longtime User Feb 16, 2015 #1 Hi all, I have a homescreen widget, when the screen orientation is changed, I want to load a corresponding layout, e.g portrait_layout, landscape_layout. Also, when the screen orientation is changed, my widget data is lost, e.g my textbox all blank. I read Peter Simpson solution by using a timer to catch the rotation. Is there other solution for this, because I dont want to run the widget so frequent as it may drain much battery.
Hi all, I have a homescreen widget, when the screen orientation is changed, I want to load a corresponding layout, e.g portrait_layout, landscape_layout. Also, when the screen orientation is changed, my widget data is lost, e.g my textbox all blank. I read Peter Simpson solution by using a timer to catch the rotation. Is there other solution for this, because I dont want to run the widget so frequent as it may drain much battery.
Erel B4X founder Staff member Licensed User Longtime User Feb 16, 2015 #2 Your only other option is to create the xml layout yourself and create a layout that automatically adjusts based on the width and height. Upvote 0
Your only other option is to create the xml layout yourself and create a layout that automatically adjusts based on the width and height.
D ducphu Active Member Licensed User Longtime User Feb 16, 2015 #3 So when the screen orientation is changed, the widget service is called from Service_Create or from Service_Start? Upvote 0
So when the screen orientation is changed, the widget service is called from Service_Create or from Service_Start?
Erel B4X founder Staff member Licensed User Longtime User Feb 17, 2015 #4 No. Nothing is called. Upvote 0
D ducphu Active Member Licensed User Longtime User Feb 19, 2015 #5 Hi all, I'm not good at xml. Can anyone show me an example how to modify a xml layout file, using "if" statement. For example, if screen orientation is portrait then the code is Code: <ImageView android:scaleType="fitXY" android:id="@+id/widget2x2s_imageview1" android:layout_width="20dp" android:layout_height="20dp" android:layout_x="3dp" android:layout_y="40dp" android:visibility="visible" /> If screen orientation is landscape, I want to layout_width to 15dp, layout_height to 15dp, layout_y to 30dp. Thanks in advance. Upvote 0
Hi all, I'm not good at xml. Can anyone show me an example how to modify a xml layout file, using "if" statement. For example, if screen orientation is portrait then the code is Code: <ImageView android:scaleType="fitXY" android:id="@+id/widget2x2s_imageview1" android:layout_width="20dp" android:layout_height="20dp" android:layout_x="3dp" android:layout_y="40dp" android:visibility="visible" /> If screen orientation is landscape, I want to layout_width to 15dp, layout_height to 15dp, layout_y to 30dp. Thanks in advance.
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2015 #6 You cannot add an "if" statement to a XML layout file. Upvote 0
D ducphu Active Member Licensed User Longtime User Feb 19, 2015 #7 Hi, then how am I able to create a layout that automatically adjusts based on the width and height ? Can give me an example? Upvote 0
Hi, then how am I able to create a layout that automatically adjusts based on the width and height ? Can give me an example?
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2015 #8 You will need to learn more about xml layouts (which are usually not used at all in B4A): http://developer.android.com/guide/topics/ui/declaring-layout.html Upvote 0
You will need to learn more about xml layouts (which are usually not used at all in B4A): http://developer.android.com/guide/topics/ui/declaring-layout.html