Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 13    Views: 62

RussFAR
Aspiring developer
Profile
Posts: 57
Reg: Jan 03, 2014
Buffalo, NY
4,320
01/23/14 03:22 PM (11 years ago)

Center Text in Rows?

Does anyone know how to center the text in the list menu rows? Seems simple but I don't know lol. Thanks guys! I am new to BT (today) I have one app built already and am loving this software!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/23/14 03:42 PM (11 years ago)
Congrats, and welcome to BT! Which platform are you working with? iOS or Android? It's those little things that mean a lot ;) Cheers! -- Smug
 
RussFAR
Aspiring developer
Profile
Posts: 57
Reg: Jan 03, 2014
Buffalo, NY
4,320
like
01/23/14 03:49 PM (11 years ago)
iOS for now. I have my dev account but haven't published yet. I am seeing the issues in my Xcode iOS simulator. I may noy have the plugins installed correctly. I did drag the image files over to the BT_images folder.
 
RussFAR
Aspiring developer
Profile
Posts: 57
Reg: Jan 03, 2014
Buffalo, NY
4,320
like
01/23/14 03:50 PM (11 years ago)
iOS for now. I have my dev account but haven't published yet. I am seeing the issues in my Xcode iOS simulator. I may noy have the plugins installed correctly. I did drag the image files over to the BT_images folder.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/23/14 04:11 PM (11 years ago)
Want to hear something corny? "If it's yellow, just mellow. if it's red, your app is dead". Typically a warning can be ignored. Of course, you can't ignore an error. To center the text in iOS, you have to perform the step for each plugin; there isn't a 'global' setting. 1) Decide on the menu 2) Within Xcode, navigate to the menu class files 3) Locate the class file for the menu "cell" 4) Determine the "label" that holds the text you wish to have centered 5) Add additional code that tells the label to center the text: [titleLabel setTextAlignment:NSTextAlignmentCenter]; // "titleLabel" is the name of the Label for the Text we desire centered. 6) Test until success. For instance, in the "BT_screen_menuListSimple" you would bring up the menu 'cell' implementation file (BT_cell_menuList.m) and add the line "among the others": //label for text titleLabel = [[UILabel alloc] init]; [titleLabel setClipsToBounds:YES]; [titleLabel setBackgroundColor:[UIColor clearColor]]; titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; [titleLabel setTextAlignment:NSTextAlignmentCenter]; // <-- I pasted this in... titleLabel.numberOfLines = 1; [self.contentView addSubview:titleLabel]; Hope this provides some direction. It's not rocket science, but it *is* very particular about syntax. Cheers! -- Smug
 
RussFAR
Aspiring developer
Profile
Posts: 57
Reg: Jan 03, 2014
Buffalo, NY
4,320
like
01/23/14 04:37 PM (11 years ago)
Thanks so much for the help. I can get to step 4. It is my BT_cell_menuList.m file I believe that I am looking to center the txt on. The text that is in the "rows" that is default set to left orientation. I can not find the "label". I am more of a graphics guy than a coder sorry.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/23/14 04:39 PM (11 years ago)
Which menu plugin are you using? If you're using 'Menu Simple' you would want to paste this code: [titleLabel setTextAlignment:NSTextAlignmentCenter]; around line 97 or so (of BT_cell_menuList.m)… don't overwrite or erase any existing code; augment it with this line, as long as it is *after* the line that says "titleLabel = [[UILabel alloc] init];" and *before* the line that says "[self.contentView addSubview:titleLabel];" Cheers! -- Smug
 
RussFAR
Aspiring developer
Profile
Posts: 57
Reg: Jan 03, 2014
Buffalo, NY
4,320
like
01/23/14 05:58 PM (11 years ago)
you da man!!! worked like a charm. The BT forums are the best. thanks everyone!
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
01/23/14 07:48 PM (11 years ago)
Similar question... I use the menu with image plugin for all my menus. It is centered vertically on iOS unless there is a description, which is great. But I just started with the Android version, and whether there is a description or not, the title text is always in the same spot (upper 1/3 of the row). Any way to fix this??? Josh
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/23/14 09:10 PM (11 years ago)
Mutzy, although Android is a necessary evil, it's still evil, so take anything I say with a grain of salt… Things aren't 'dynamic' with Android, so you can't really have things move around depending on whether there is a description or not. It either 'Is' or it 'Is Not'. For the Menu with Image, you'll have to work on the file called "wb_menu_row.xml" I suggest working on the xml while it is in the 'graphic' layout tab… it will automatically adjust the other elements for you, although sometimes with unexpected and unwanted results. For 'centering' the text, in android that has to do with 'gravity'. you can set the gravity of your object to align left, right, center, up, down, etc… It takes a little playing with to figure out which looks best in any situation. Otherwise, you should be able to physically 'move' the text element to the position you desire. If you have Chris1's 'MWI Advanced', he includes a choice of "list view cell" files that can be chosen in the control panel, and has separate settings for "title only, title w/description, and title/description/icon". A Bit more flexible. Good Luck! Cheers! -- Smug
 
MichM
Aspiring developer
Profile
Posts: 13
Reg: Feb 08, 2015
California
830
like
02/19/15 09:37 PM (10 years ago)
I know this thread is old, but will this work on Android for the current version of BT and the Menu Simple plugin?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/20/15 12:59 AM (10 years ago)
Let me know if it doesn't. If not, I'll open Eclipse and figure it out. Cheers! -- Smug
 
MichM
Aspiring developer
Profile
Posts: 13
Reg: Feb 08, 2015
California
830
like
02/20/15 09:26 PM (10 years ago)
Thanks Smug! I believe I figured it out. Its different for Menu Simple for Android. I accomplished it using your advice, "working on the xml while it is in the 'graphic' layout tab". I'll come back and write up detailed instructions for future newbies who want to use the Menu Simple for Android and have the text centered in the row buttons. Android doesn't show the arrow on the right side of each row(or I havent gotten it to work) like Apple does, so having the text aligned on the left, doesn't look balanced.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/20/15 10:24 PM (10 years ago)
You're going to find 'a lot' of things that are different between the two. And you'll find as many Android fans or Apple fans saying how it's better than the other. Worse than politics, sometimes, lol! My 'personal' experience is that Apple tends to be a little easier. But that's also because I have more experience with ObjC than I do Java. I'm sure if I had as much Java experience I wouldn't moan and groan as much. Usually it's the layouts in Android that send me over the cliff. Nice work on the menu! Look forward to your contributions :) Cheers! -- Smug
 

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.