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: 4    Views: 93
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
11/19/12 06:46 AM (11 years ago)

Small issue with menu text

Hi Susan,

Great plugin, thanks! Really like the row images, but I've come across a small issue on newer android devices..

On an older device (2.2) it's fine, no problem.

On a newer device (4.0.3) The first letter of the title text is behind the row image. I've tried the tablet fix in the java class (lp.addRule(RelativeLayout.CENTER_VERTICAL);) but that doesn't work.

I thought at first that the title might be too long, but it's the same with a one word title. Tried various margin, padding and alignment settings but can't get it right!

Paul.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
11/19/12 09:30 AM (11 years ago)
ok, I've got the layout looking quite good now. Tested on htc one x (4.0.3) htc wildfire (2.2) and Packard Bell Liberty Tab 10.1" tablet (not sure which version but it's ics).

Haven't used the description text in the rows, just the title. On older device the title text is a little too far to the right, but it's ok, and as it's an older device I thought it wouldn't matter as much..

Here are the changes if you would like to test them for a potential update?

java file around line 701:

//added by SAS
///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 = 5;
lp.rightMargin = 45;
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);
// modified settings
lp.leftMargin = 55; lp.addRule(Gravity.LEFT);
lp.rightMargin = 25; lp.addRule(Gravity.LEFT);
lp.addRule(Gravity.LEFT);
// end
titleView.setLayoutParams(lp);
descriptionView.setLayoutParams(lp);
}

xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/containerView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:minHeight="?android:attr/listPreferredItemHeight" >

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
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="10dip"
android:paddingLeft="25dip"
android:singleLine="true"
android:textColor="#CCCCCC"
android:ellipsize="end">
</TextView>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
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="10dip"
android:paddingLeft="25dip"
android:singleLine="false"
android:textColor="#CCCCCC"
android:ellipsize="end">
</TextView>


<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/iconView"
android:layout_height="50dip"
android:layout_width="50dip"
android:maxHeight="50dip"
android:maxWidth="50dip"
android:scaleType="fitStart"
android:layout_centerVertical="true"
android:layout_marginLeft="1dip"
android:layout_alignParentLeft="true"
android:layout_marginRight="1dip">
</ImageView>



<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/indicatorView"
android:layout_height="30dip"
android:layout_width="30dip"
android:maxHeight="30dip"
android:maxWidth="30dip"
android:scaleType="fitEnd"
android:layout_centerVertical="true"
android:layout_marginLeft="32dip"
android:layout_alignParentRight="true"
android:layout_marginRight="2dip">
</ImageView>


</RelativeLayout>

 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
11/19/12 09:50 PM (11 years ago)
Thank you, Paul! I owe you a huge favor. I will get it submitted to buzztouch tomorrow. I need to get a tablet for testing--I have a tablet emulator set up, but I always struggle with it. What do you think about the Nexus 7? Would it be a good choice for testing purposes?
 
OrchardApps
Code is Art
Profile
Posts: 115
Reg: Jan 11, 2012
Brisbane austra...
5,850
11/27/12 05:18 PM (11 years ago)
I had written a silly questions, but figured it out. Would delete this if I could.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
12/11/12 09:28 PM (11 years ago)
Here is the code to make the set margin correctly on add devices. I will include this in the file you download as soon as possible. This alternative only requires a change to the java file.

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);
}



The first couple lines of code are new--you can see the screen density in the logcat. I have it set as 60, but I'm not sure of the best number yet. 55 may be better.

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);
}

 

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.