Android layout PX to SP - android-layout

I have been reading it is recommended to indicate EditText or TextView textSize attribute in sp. The thing is that my requirements indicate me 40px, but nothing regarding sp.
So, how can I convert these px in order to set sp into my layout?

Related

views order change when ad loads

Im working on a simple crosswords application,the main layout is this
http://imageshack.us/a/img802/6618/9v8c.png
a fragment at the top the load ads so ads be present on any application page , the below fragment have a linearlayout for the crossword table, under it 2 linearlayouts , one for hints and the other for keyboard and all the 3 linearlayouts under a linearlayout with vertical orientation
okay now when ad refresh or when i press the power button and power on to resume app again , (and on some devices when filling any of the table squares)
this happen
http://imageshack.us/a/img818/5125/lk8v.png
the crosswords linearlayout comes below other 2 layouts as shown and also the squares inside the lnearlayout gets randomized, i load the crosswords iems in an asynktask on the oncreateview method of the fragment
so my question is any1 know where to look at that makes this mess, i even tried a tablelayout and still same problem
the mess on view orders was caused by calling view.bringToFront();
i was calling it before animating every square, took it off and eveery

Change layout no internet access admob (Android)

I want to change the properties of my layout, like the margins or the position (above, rigth of, left of..) when there's not internet access and AdMob ads cannot be shown. I don't know how to change these layout properties in my activities and set the layout to full screen. Anyone can help me? Thanks
If the layout is occurring in a LinearLayout, Set the addView layout's visibility to View.GONE
If you are using a RelativeLayout and using margins to prevent the addLayout overlapping your content, then try something like this:
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(0,0,0,0);
myLayout.setLayoutParams(lp);

how to know the height of a control? I get NaN

I have an application that use the MVVM pattern. In the main view model, I create a view and its viewmodel of another control.
I need to know the height of the control, but when I create the control, if I see the Height value of the control I get NaN.
I use this code in my main view model:
miSecondControl = new mySecondControl(param1, param2);
double myHeight = miSecondControl.height;
This secondary control does not use the MVVM patter but it has code behind, because I only want to use it to print a fixed document, so I think that in this case MVVM would make more complex the solution.
I need the heigh property of the control to know if I need to create a new page because I don't have space in the actual page.
Thanks.
Height/Width are values that are specified at design/layout time.
Use FrameworkElement.ActualHeight and FrameworkElement.ActualWidth to get the rendered Height/Width of a control.

javafx 2.0 TitledPane how to change the title text to image+text

the default title only contains text, just like the "Apples" title in the above image.
is that possible to add image in the title.
or
is there a way developer can build a customized TitledPane ?
thanks
Use setGraphic method
TitledPane tp = new TitledPane("hi");
tp.setGraphic(new Rectangle(10, 10));
As far as I know, you can set the graphics via the css property "-fx-graphic" as well.
See Oracle Defintion for JFX and CSS, here for elements of type Labeled.
To remove the button completely, you could either
set tp.setCollabsible(false); or
use the .titled-pane CSS class to set the property "-fx-collapsible" to false.
See Here (same side as above, but for TitledPane).

I want a different title to appear in the navigation bar for each imageview in my scroll view (xcode 4.2, iOS 5.0)

I have a scroll view, and when a user moves from one imageview to the next, I want the title in the navigation bar to change. So I want to set a new title for the navigation bar for each image in the scroll view. How would I go about doing this?
Thank you very much for your help.
Write a delegate for your scroll view. In the delegate, implement the scrollViewDidScroll: method to figure out which image is currently visible and change the title.
To eliminate your incompatible type warning, you can declare that ScrollViewController adopts the UIScrollViewDelegate protocol:
#interface ScrollViewController : UIViewController <UIScrollViewDelegate>

Resources