mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
07/27/13 06:31 PM (12 years ago)

Menu with Image Android (.xml totally ignores me)

Hi guys, Trying to make the second line and title of the Menu with Image move more to the right, however, the XML lines completley ignore me no matter what value I input. The second line and title stay in thier place no matter what. These are the lines I am trying to change in: res/layout/wb_menu_row.xml <TextView android:id="@+id/titleView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingTop="5dip" android:paddingBottom="0dip" android:layout_marginRight="60dip" android:layout_marginLeft="0dip" android:singleLine="true" android:textColor="#CCCCCC" android:ellipsize="end"> </TextView> <TextView android:id="@+id/descriptionView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:paddingTop="30dip" android:paddingBottom="0dip" android:layout_marginRight="60dip" android:layout_marginLeft="0dip" android:singleLine="false" android:textColor="#CCCCCC" android:ellipsize="end"> </TextView> No matter WHAT I place in android:layout_marginRight or android:layout_marginLeft, both stay in thier place. I clean the project and recompile. Other value changes to the IconView work fine. Any idea? Tearing out my hair David.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/27/13 07:08 PM (12 years ago)
It may (or may not) work for you, but what I did was leave the XML files alone, and worked in the code. For Menu with Image in the WB_screen_menuimage.java file around line 688 or so, change the 'lp.leftMargin' value from 5 (or 75) to something larger. This pushed my text to the right, and left the (sometimes overlapping) icon image where it was. Cheers! -- Smug
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
07/27/13 07:23 PM (12 years ago)
I think that did the trick, thanks Smug! So weird that the XML file totally ignores everything. I hate android. David
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/27/13 07:27 PM (12 years ago)
Lol! I don't hate it, but I do treat it like my weird cousin harold... :) Cheers! -- Smug
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
07/28/13 05:41 AM (12 years ago)
Not so weird mate. Android is so flexible that code can be written in many different ways to achieve the same results. Sure, the 'norm' is to control layout dimensions in xml, but BT controls a lot of dimensions within the java files, so dimensions can be passed from the bt control panel to the code via JSON. You could argue that the BT approach is 'weird', (I prefer 'unique and visionary' :)) not the default Android approach. You may unwittingly be mistaking your hate of Android with hate of BT :p
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
07/29/13 05:57 AM (12 years ago)
Here's the 'why'... In Android, everything is done in Java code. Everything. In the onCreate method, the XML file is loaded and turned into Java. Any code affecting elements in the XML file after that point override. (Like iOS, Java is primarily a top to bottom approach). So, code that changes the margins half way down the .java file will override the XML file, and so changing that setting on the XML file will have no effect. Hope that makes things a bit easier to understand. In fact, to compare to iOS even more, it's very much like a .xib file that is changed in code. Little known secret: .xib files are really just XML files! :)
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
07/29/13 08:45 AM (12 years ago)
Chris, Excellent post, it all makes sense now. Now the question is: why did the plugin owner decide to hardcode it rather then let the XML file do the work ? (or at least take the values out of the xml file if they are nullified) From now on I will start checking both files when something like this happens! How was your camping trip Chris? David
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
07/29/13 09:27 AM (12 years ago)
Well, code provides the flexibility and dynamic nature of logic. Also, it can serve as a documentation tool for anyone trying to follow along. As for camping, it wasn't the best trip. My 1 year old son was sick the whole time and it was cold, windy, overcast and rainy. Oh well. ;)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.