Android Question Any Java Expert here :)

ilan

Expert
Licensed User
Longtime User
hi

i need help, please.

i am using RSPopUpMenu.
what i have understood its the native popup menu by android.
now i would like to change the font size of the items.

i found this: https://stackoverflow.com/questions...xt-color-and-size-of-a-pop-up-menu-in-android

(answer nr1)

but i dont understand how to implement it in Manifest.
i also created an xml file but i guess i did it wrong.

can someone help me please?

thanx, ilan
 

JordiCP

Expert
Licensed User
Longtime User
Unless you have a special reason to use rspopumenu, you could use AppCompat popup menus as in this example and change last part of manifest

B4X:
  <style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
    <item name="android:textColor">#FF0000</item>
     <item name="android:textSize">44sp</item>     '<--------------------HERE
   </style>

or even easier with CSBuilder if you want different sizes for individual items
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Unless you have a special reason to use rspopumenu, you could use AppCompat popup menus as in this example and change last part of manifest

B4X:
  <style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
    <item name="android:textColor">#FF0000</item>
     <item name="android:textSize">44sp</item>     '<--------------------HERE
   </style>

or even easier with CSBuilder if you want different sizes for individual items

thank you Jordi.

i really need to learn JAVA soon, i have signed up to a Java Course (+Swift) in the Technion and it had should start at May/2017 but something went there wrong and they moved the Course to September/2017 :(

so i guess i will need to wait but i really hope there wont be any surprises anymore.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Let's hope this time is the good one (and it's worth the time & money!!)
Swift--> also in my to-do list :)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Let's hope this time is the good one (and it's worth the time & money!!)
Swift--> also in my to-do list :)

Cost = 16.000 shekel (+/- 4500 $)
I can learn java and swift by myself but i also need the certificate to find a job in this branch.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
This question is not really related to Java. It is related to Android resources system.

Sorry my mistake, but i thought that when you code in java you use those xml setting. So a jave expert should know it (i guess).
So i pointed my question to java experts.

Anyway thanx to b4x that saves us that headache. :)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Unless you have a special reason to use rspopumenu, you could use AppCompat popup menus as in this example and change last part of manifest

B4X:
  <style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
    <item name="android:textColor">#FF0000</item>
     <item name="android:textSize">44sp</item>     '<--------------------HERE
   </style>

or even easier with CSBuilder if you want different sizes for individual items

hi jordi

i just noticed that you copied the xml part from the original post but what i needed was how to implement it in b4a manifest.
copy/paste wont work.

btw using csBuilder doesnot change anything.
i guess the lib auto format all labels again.

B4X:
    Dim cs As CSBuilder
    PopupMenu.Initialize("PopupMenu", lbl)
    PopupMenu.AddMenuItem(0, 0, cs.Initialize.Color(Colors.Green).Size(8).Append("View").PopAll)
    PopupMenu.AddMenuItem(1, 1, "Edit")
    PopupMenu.AddMenuItem(2, 2, "Details")
    PopupMenu.AddMenuItem(3, 3, "Remove")
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
How strange, it works for me (using Erel's example). I even tested because I was bored :D

1st option: --> add that line to the manifest (it isn't there in the original example)
B4X:
<item name="android:textSize">44sp</item> '<--------------------HERE
Screenshot_2017-06-20-17-53-37-602_b4a.example.popup.png
2nd option.--> Without adding that line in the manifest, and using CSBuilder (just checked it and if the line is present, overrides size changes of CSBuilder)
Screenshot_2017-06-20-17-55-18-866_b4a.example.popup.png


The only explanation I can think of is that there is more than one "myPopupMenuStyle" and depending on device density (just a guess) is using one or the other. In my case the used one was the third. But if you put the same line in all three should give the desired effect (or if you remove it from all three, then it should be possible to change size with CSBuilder)
B4X:
  <style name="myPopupMenuStyle" parent="@style/Widget.AppCompat.Light.PopupMenu">
     <item name="android:popupBackground">#FF0AECD3</item>
<item name="android:textSize">44sp</item> '<-------------------- PERHAPS ALSO HERE
   </style>
   <style name="myPopupMenuTextAppearanceSmall" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small">
    <item name="android:textColor">#FF0000</item>
<item name="android:textSize">44sp</item> '<-------------------- AND HERE
   </style>
   <style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
    <item name="android:textColor">#FF0000</item>
<item name="android:textSize">44sp</item> '<-------------------- AND HERE (this is the one that worked in my device)
   </style>
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
How strange, it works for me (using Erel's example). I even tested because I was bored :D

1st option: --> add that line to the manifest (it isn't there in the original example)
B4X:
<item name="android:textSize">44sp</item> '<--------------------HERE
2nd option.--> Without adding that line in the manifest, and using CSBuilder (just checked it and if the line is present, overrides size changes of CSBuilder)


The only explanation I can think of is that there is more than one "myPopupMenuStyle" and depending on device density (just a guess) is using one or the other. In my case the used one was the third. But if you put the same line in all three should give the desired effect (or if you remove it from all three, then it should be possible to change size with CSBuilder)
B4X:
  <style name="myPopupMenuStyle" parent="@style/Widget.AppCompat.Light.PopupMenu">
     <item name="android:popupBackground">#FF0AECD3</item>
<item name="android:textSize">44sp</item> '<-------------------- PERHAPS ALSO HERE
   </style>
   <style name="myPopupMenuTextAppearanceSmall" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small">
    <item name="android:textColor">#FF0000</item>
<item name="android:textSize">44sp</item> '<-------------------- AND HERE
   </style>
   <style name="myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
    <item name="android:textColor">#FF0000</item>
<item name="android:textSize">44sp</item> '<-------------------- AND HERE (this is the one that worked in my device)
   </style>

sorry for the misunderstanding.
i am talking about RSPopUpMenu: https://www.b4x.com/android/forum/threads/rspopupmenu.43602/#content

and there the csbuilder is not working.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
sorry for the misunderstanding.
i am talking about RSPopUpMenu: https://www.b4x.com/android/forum/threads/rspopupmenu.43602/#content

and there the csbuilder is not working.
Yes, it doesn't work with CSBuilder.
I have just made it to work. Manifest editor should be similar to this

B4X:
.....
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@style/RSPopupMenu")    '<------------important!! 
'End of default text.
CreateResource(values, theme.xml,
<resources>
<style name="RSPopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
<item name="android:textColor">#FF0000</item>     '<-----------red
<item name="android:textSize">48sp</item>           '<-----------size
</style>
</resources>
)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Wow thanks a lot i will try it out when i get to my pc. :)

Ps i have big plans with your ocv lib.

Just need more time :(
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
what i needed was how to implement it in b4a manifest
Nothing.

You need to create a new style based on a theme. This can be done with creating a resource (#additionalres) and here you need to create a style.xml in res/values/

See https://developer.android.com/guide/topics/resources/style-resource.html

But, away from this, i too suggest to use @corwin42 Version. Probably it is the same Android Object wrapped in AppCompat....


Edit: Based on @JordiCP answer in #11 it is not the style.xml but the theme.xml.
Maybe both are possible
 
Upvote 0
Top