Plugin Discussions

Discussions are between the Plugin Developer and app owners. Only app owners that have installed the plugin can participate in this discussion. We enforce this to help Plugin Developers focus their time on helping app owners that support the development efforts.

pointerBack to discussions for "Menu with Image"
Replies: 3    Views: 197
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
02/12/13 02:49 PM (11 years ago)

Android Fix: Text overlaps icon on new devices

This will no longer be necessary when the new release of the plugin is out. On some newer devices, this code is necessary to avoid the text overlapping the icon. The newer devices interpret the dip differently.

First, here is the code to make the set margin correctly on add devices. First, here is the corrected code: It should be around line 687:

//Get the screen density of the device
float scale = getResources().getDisplayMetrics().density;
BT_debugger.showIt(activityName + "This is what scale is: " + scale);

///Set location for text if there is or is no icon
if(icon == null){

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

lp.leftMargin =(int)( 5 * scale);
lp.rightMargin = (int)( 45 * scale);
lp.addRule(RelativeLayout.CENTER_VERTICAL);
titleView.setLayoutParams(lp);

descriptionView.setLayoutParams(lp);
}else
{
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

lp.leftMargin = (int)( 60 * scale);
lp.rightMargin = (int)( 45 * scale);

lp.addRule(RelativeLayout.CENTER_VERTICAL);
titleView.setLayoutParams(lp);
descriptionView.setLayoutParams(lp);
}



This is the old code that you should comment out or replace with the text above:

///Set location for text if there is or is no icon
if(icon == null){

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
lp.leftMargin = 5;
lp.rightMargin = 45;
titleView.setLayoutParams(lp);
descriptionView.setLayoutParams(lp);
}else
{
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
lp.leftMargin = 75;
lp.rightMargin = 45;
titleView.setLayoutParams(lp);
descriptionView.setLayoutParams(lp);
}
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
04/10/13 04:36 PM (11 years ago)
@Susan Thanks for this fix. Is there an ETA on the new release?

Jake
 
Iaxia
I hate code!
Profile
Posts: 108
Reg: Feb 04, 2012
Toronto
7,080
04/23/13 02:50 PM (11 years ago)
Nevermind! Deleted comment.
 
pimentazores
Aspiring developer
Profile
Posts: 47
Reg: Mar 26, 2013
Barcelona
8,020
04/28/14 03:08 PM (9 years ago)
Hi Susan,
I'm having the same problem now with the menu image, the text overlapping the icon. Since the plugin's code has changed since this post, can you please give me a help?/

Tks in advance.

Pedro
 

You cannot participate in this discussion yet.

  1. You must be logged in to participate
  2. You must have a screen name setup in your profile
  3. You must have installed the plugin in your control panel.