What is difference between Android widget position left and start (or right and end) for create Constraint? - android-layout

For example, if i want to position button B to the right of button A.
Relative Positioning Constraints:
I can to use:
1)<Button android:id="#+id/buttonB" ...
app:layout_constraintLeft_toRightOf="#+id/buttonA" />
Or
2)<Button android:id="#+id/buttonB" ...
app:layout_constraintStart_toRightOf="#+id/buttonA" />
What is difference between example 1 and 2?
References: https://developer.android.com/reference/android/support/constraint/ConstraintLayout

There is no as such difference in both . As you can see in you image , they have mentioned above left as start and right as end .
start and end was introduced in API level 17 What is the difference between Android margin start/end and right/left?
Even if you try to use
<Button android:id="#+id/buttonB" ...
app:layout_constraintStart_toEndOf="#+id/buttonA" />
will result the same as
<Button android:id="#+id/buttonB" ...
app:layout_constraintLeft_toRightOf="#+id/buttonA" />
But i didn't find this constraint till now ... mixture of both start and right. Even this didn't appeared in xml .
app:layout_constraintStart_toRightOf

Right/left versus start/end
"Right" and "left" always refer to the right and left sides of the
screen, whether your app uses a left-to-right (LTR) flow or a
right-to-left (RTL) flow. "Start" and "end" always refer to the start
and end of the flow:
For a LTR flow, start = left and end=right. For a RTL flow,
start=right and end=left. If your app targets API level 17 (Android
4.2) or higher:
Use "start" and "end" instead of "left" and "right". For example,
android:layout_marginLeft should become android:layout_marginStart to
support RTL languages. If you want your app to work with versions
lower than Android 4.2; that is, if the app's targetSdkVersion or
minSdkVersion is 16 or lower:
Add "start" and end" in addition to "left" and "right". For example,
use both android:paddingLeft and android:paddingStart.
Source: kotlin-android-training by Google

Related

CMFCToolbar and CMFCMenubar displaying wrong tooltips

Question asked also on https://social.msdn.microsoft.com/Forums/vstudio/en-US/f64c99e5-f490-454f-951f-aee794e9506b/cmfctoolbar-and-cmfcmenubar-displaying-wrong-tooltips
I am using Visual Studio 2010, but I suspect the bug is still present on the 2013 version, as I compared the winfrm.cpp file and the OnToolTipText are exactly equal on the two files.
The bug is happening always at the 7th, 8th or 16th element.
Although separators count as elements for this counting, the tooltips do not appear over them.
Element can be a textual MENUITEM, a POPUP menu or toolbar button.
The string table defines are:
#define IDS_SEVEN 7
#define IDS_EIGHT 8
#define IDS_NINE 9
#define IDS_TEN 10
#define IDS_ELEVEN 11
#define IDS_TWELVE 12
#define IDS_THIRTEEN 13
#define IDS_FOURTEEN 14
#define IDS_FIFTEEN 15
#define IDS_SIXTEEN 16
and the STRINGTABLE contents are:
IDS_SEVEN "Seven"
IDS_EIGHT "Eight"
IDS_NINE "Nine"
IDS_TEN "Ten"
IDS_ELEVEN "Eleven"
IDS_TWELVE "Twelve"
IDS_THIRTEEN "Thirteen"
IDS_FOURTEEN "Fourteen"
IDS_FIFTEEN "Fifteen"
IDS_SIXTEEN "Sixteen"
So, when I hover with the mouse pointer the 7th, 8th or 16th element I get WRONGLY a tooltip displaying the string with that ID (Example:7th element displays "Seven").
It happens with all my toolbars and all my menus with a sufficient number of items, including in the toplevel horizontal menubar.
I discovered that the guilty function is:
BOOL CFrameWnd::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
as the nID local variable does not get the ABSOLUTE ID of the Command, but the POSITIONAL order of the button, starting with 1 instead of 0.
If I would move the strings IDs out of that range, whenever a user wants to add new strings, the Visual Studio Resource Editor would see that space free and use it, filling it again. And the problem would happen again. So, it is not a valid solution.
I could also define strings for all commands. But as we are maintaining four TFS branches at the same time and the change needs to go to all branches, this change would be potentially very dangerous when doing merges after.
So, please what solution do you recommend to not display those stupid tooltips?
UPDATE: I didn't copy the string table exactly as it was. It was like this:
IDS_SEVEN "Seven\nSeven"
IDS_EIGHT "Eight\nEight"
IDS_NINE "Nine"
IDS_TEN "Ten"
IDS_ELEVEN "Eleven"
IDS_TWELVE "Twelve"
IDS_THIRTEEN "Thirteen"
IDS_FOURTEEN "Fourteen"
IDS_FIFTEEN "Fifteen"
IDS_SIXTEEN "Sixteen\nSixteen"
In the update I put a stringtable more similar to the one I had. I had not noticed before a common feature of 7, 8 and 16 th strings: they all had '\n' characters in their contents.
I think nobody will create a menu with more than 512 menuitems nor toolbars with more than 512 buttons, so my solution was to change all strings containing '\n' characters with an ID below 512 to numbers above 512.
And it works.

How to create TI-BASIC (TI-84+) input forms?

In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
You've set a rather tall order for TI-Basic to fill. user3932000 is correct; there is no built in function to create an input form of the type you request.
However, there is nothing stopping you from creating an interactive interface yourself. Creating it from scratch will be a time consuming and, it will consume a significant amount of memory on your calculator. There is no boilerplate code you plug your variables into to get the results you want, but you might have some luck modeling it after this quadratic solver I wrote.
ClrHome
a+bi
Output(1,1," QUADRATIC
Output(2,1," AX²+BX+C
Output(3,1,"ZEROS:
Output(6,1,"A=
Output(7,1,"B=
Output(8,1,"C=
DelVar YDelVar D
" →Str1
While Y≠105
getKey→Y
If Ans
Then
Output(X,4,Str1
Output(3,7,Str1+Str1+Str1+"
End
X+(Ans=34)-(Ans=25
If Ans<6:8
If Ans>8:6
Ans→X
Output(Ans,16,"◄
D(Y≠45→D
If Y=25 or Y=34
sum({A,B,C}(X={6,7,8→D
If Y=104:⁻D→D
10not(Y)+Y(102≠Y)-13int(Y/13(2>abs(5-abs(5-abs(Y-83
If Ans≤9
D10+Ans-2Ans(D<0→D
If X=6:D→A
If X=7:D→B
If X=8:D→C
If A
Then
2ˉ¹Aˉ¹(⁻B+{1,⁻1}√(B²-4AC
Else
If B
Then
⁻C/B
Else
If C
Then
"No Zeros
Else
"All Numbers
End
End
End
Output(3,7,Ans
Output(6,3,A
Output(7,3,B
Output(8,3,C
End
ClrHome
Ans
Here's a GIF of what it does for you.
With a little more work. This code could be used on the Graph screen instead of the home screen, giving more option in terms of layout and design.
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
There are many ways to ask for input in your program:
Prompt: Asks for input and stores it in a variable. For example, Prompt A. Simplest way to ask for input, but not very visually appealing.
Input: Similar to the Prompt command, except that now you can include text within the input. For example, Input "What is your name?",A.
Menu(: Multiple choice input, and each choice is connected to a Lbl marker somewhere else in the script. Much like the error screen with the quit/goto choices that you've probably seen. For example, Menu("Are you a boy or a girl?","Boy",B,"Girl",G).
getKey: Checks if a certain key is pressed, and will output True (1) if that key is pressed. For example, getKey 105. See here for which numbers each key corresponds to.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function http://imgur.com/ulthDRV
I'm afraid that's not possible in programs. You can either put in multiple inputs, or you might be interested in looking into making apps instead.
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
If you're talking about the text on top of the screenshot, yes you can; just put a Disp command or something after each line of Input, so that it continuously overwrites the text above with new text after you input a variable.

How to use Modern UI Icons in AppBarButton

I'm developing a Windows 8.1 Store App. I have a CommandBar control with a couple of AppBarButtons inside. Using the standard icons is easy, I just set the icon property to the appropriate string like so :
<AppBarButton Icon="Download" Label="Download Files"/>
I'd like to use a couple of custom icons from the very nice free collection Modern UI Icons. Ideally, I'd like to be able to set the icon property in much the same way :
<AppBarButton Icon="transit.distance.to" Label="Distance to destination"/>
This would refer to this icon : PNG / XAML
Is this possible ?
If not, what are the alternatives ?
Tim Heuer proposes using a font file, although at present the font files available here only cover a sub-set of the icons, and also this code is quite unreadable :
<FontIcon FontFamily="ms-appx:///modernuiicons.ttf#Modern-UI-Icons---Social" Margin="0,2,0,0" Glyph="" FontSize="37.333" />
Would you believe that shows a twitter icon?!
Tim Heuer also proposes using vector data, and one of the commenters explains how the vector data can be rolled into a style. I could do that, but then I would have to copy and paste the path data for each icon I want to include ?
Should I be using the PNG files, as explained in this question ? That looks pretty messy as well.
What a nightmare!
I'm not sure what the nightmare part is -- you want to use a custom icon that isn't present in the 200+ supplied defaults. You have options:
Use SymbolIcon and supply your own font. You note that you don't like that the code feels unreadable. Unicode ranges are universally used for symbol fonts and I agree that Unicode isn't human-readable, but a simple code comment would help ;-) Fonts give you the most ease and flexibility because they are also vectors.
PathIcon. You convert your image into vector geometries we can render. This would be the second best, but also requires a bit fine tuning of the vectors to get right. For people not familiar with working with geometries this can be annoying at first. Blend and Inkscape are helpful tools here.
BitmapIcon. This would allow you to use your PNG, however you now must supply multiple of them for different scales and states. This is my least favorite option as it requires most work, but for some may be the simplest. Now your problem you will hit is there is an issue with BitmapIcon for non-rectangular shapes (which looks like your icon is). This won't have the fidelity you seek due to a bug in rasterizing.
Contact metroicon author and see if he can put it into the font file so you can use option #1 :-)
Maybe this is what you're looking for:
<AppBarButton Label="Transit">
<AppBarButton.Icon>
<PathIcon Data="F1 M 3.912,17.38C 4.89067,17.38 5.688,18.2653 5.688,19.3586C 5.688,20.448 4.89067,21.3333 3.912,21.3333C 2.92667,21.3333 2.136,20.448 2.136,19.3586C 2.136,18.2653 2.92667,17.38 3.912,17.38 Z M 16,17.38C 16.984,17.38 17.776,18.2653 17.776,19.3586C 17.776,20.448 16.984,21.3333 16,21.3333C 15.016,21.3333 14.224,20.448 14.224,19.3586C 14.224,18.2653 15.016,17.38 16,17.38 Z M 21.3333,18.9626L 18.464,18.9626C 18.292,17.62 17.2547,16.5933 16,16.5933C 14.7453,16.5933 13.708,17.62 13.536,18.9626L 6.37467,18.9626C 6.20267,17.62 5.16667,16.5933 3.912,16.5933C 2.656,16.5933 1.62,17.62 1.448,18.9626L 0,18.9626L 0,10.2706C 0,9.396 0.636,8.69196 1.42133,8.69196L 19.5573,8.69196C 20.3387,8.69196 20.9787,9.396 20.9787,10.2706M 20.4427,10.2706L 19.1973,10.2706L 19.1973,15.8013L 20.62,15.8013M 17.776,13.432L 17.776,10.2706L 14.224,10.2706L 14.224,13.432M 13.5107,10.2706L 9.95333,10.2706L 9.95333,13.432L 13.5107,13.432M 9.24533,10.2706L 5.688,10.2706L 5.688,13.432L 9.24533,13.432M 4.97867,10.2706L 1.42133,10.2706L 1.42133,13.432L 4.97867,13.432M 14.5787,2.36932L 12.4427,0L 15.2867,0L 17.776,2.45862L 17.776,0L 19.1973,0L 19.1973,6.31732L 17.776,6.31732L 17.776,3.85864L 15.2867,6.31732L 12.4427,6.31732L 14.5787,3.948L 7.73467,3.948C 7.41733,5.31195 6.30267,6.31732 4.97867,6.31732C 3.40667,6.31732 2.136,4.90533 2.136,3.16132C 2.136,1.41064 3.40667,0 4.97867,0C 6.30267,0 7.41733,1.00531 7.73467,2.36932L 14.5787,2.36932 Z " HorizontalAlignment="Center" VerticalAlignment="Center"/>
</AppBarButton.Icon>
</AppBarButton>
Hope this helps!

JavaFX proximity detection not working

I have been trying to figure out how to get two nodes to sense when they are close to each other and then snap together but can't make it work correctly. Basically, I have an AnchorPane that I am dropping new Nodes onto. The new nodes are also anchor panes with several other components on them. When I drop the Node I save anchor points along the outer edge. Then, when I drag another Node next to it, the sides will light up indicating the other node is in range.
I am attempting to make a node that is being dragged next to another node snap to that node. I cannot seem to get the coordinates to translate correctly between each other and I am just ending up with random placement and edge detection.
Here is my code where I am saving the anchor points for the nodes:
double kromaDeviceWidth = kromaDevice.getBoundsInParent().getWidth();
double kromaDeviceHeight = kromaDevice.getBoundsInParent().getHeight();
//This x,y represents the top left corner of the node
double kromaDeviceX = kromaDevice.localToParent(0.0, 0.0).getX();
double kromaDeviceY = kromaDevice.localToParent(0.0, 0.0).getY();
kromaDevice.setTopAnchorPoint(new double[]{kromaDeviceX + kromaDeviceWidth / 2, kromaDeviceY});
kromaDevice.setRightAnchorPoint(new double[]{kromaDeviceX + kromaDeviceWidth, kromaDeviceY + kromaDeviceHeight / 2});
kromaDevice.setBottomAnchorPoint(new double[]{kromaDeviceX + kromaDeviceWidth / 2, kromaDeviceY + kromaDeviceHeight});
kromaDevice.setLeftAnchorPoint(new double[]{kromaDeviceX, kromaDeviceY + kromaDeviceHeight / 2});
The code is identical for when I initially drop a new node and when I am dragging the node. Then, I compare the two node's anchor positions to tell if they are within range:
if (Math.abs(bottomAnchorX - topAnchorPointX) <= ANCHOR_DISTANCE && Math.abs(bottomAnchorY - topAnchorY) <= ANCHOR_DISTANCE) {
....show correct edge highlight
}
I simplified the above if statement as I am using arrays to store and recall the anchor points.
Here is an image of what I am seeing:
You can see the slight yellow highlight when I drag one node over the other when it is offset. It should detect the other node when it is in the position in the second image. My next issue is trying to get them to snap to the right coordinates.
droppedKromaDevice.setLayoutX(parentKromaDevice.getLayoutX());
droppedKromaDevice.setLayoutY(parentKromaDevice.getLayoutY() - droppedKromaDevice.getBoundsInParent().getHeight());
I tried the above with both getLayoutX() and localToParent(0,0).getX() and they produce the same result. If I place two nodes that are exactly the same size than it actually works but if the are different sizes at all than it places them offset from each other. If I subtract the height from the y it should matter the size.
Please help. I have been trying to get this to work right for 3 days now and have tried everything I can think of.
Update:
I figured out my proximity issue. The layout for the new node was not being set right. I tried doing a Platform.runLater before I saved the anchor points of the new node but that had no impact. I fixed it by setting the anchor points for all of the nodes in the pane when I click on a node to drag it. That saved the anchor points correctly.
This however did not fix my issue of nodes of different sizes not laying out in the pane correctly. Here is a screenshot of two nodes of the same size snapping together correctly and two nodes of different sizes not snapping correctly. This makes no sense as the math should be the same.
Here is the code to set the layout for the dropped node relative to the other node:
droppedKromaDevice.setLayoutX(parentKromaDevice.getLayoutX());
droppedKromaDevice.setLayoutY(parentKromaDevice.getLayoutY() - droppedKromaDevice.getBoundsInParent().getHeight());
I found the solution to my two problems.
First, when I was creating new nodes and dropping them on the panel the bounds were not being evaluated correctly so my anchor points were off. I just changed it so when I click on a node to drag it around I loop through all of the other nodes on the panel and build their anchors instead of when I first drop/create it.
Second, in order to get the snap positioning to work accurately I had to base their layout on the delta between the opposite anchor points and not on the bounds of the node. Basically, I get the current x/y of the node I am dropping and than move it using the delta between the dropped node and the node I need to snap it to. The code below is what I used. 0 represents the x coordinate and 1 represents the y coordinate in the array
droppedKromaDevice.setLayoutX(droppedKromaDevice.getLayoutX() - droppedKromaDevice.getBottomAnchorPoint()[0] + parentKromaDevice.getTopAnchorPoint()[0]);
droppedKromaDevice.setLayoutY(droppedKromaDevice.getLayoutY() - droppedKromaDevice.getBottomAnchorPoint()[1] + parentKromaDevice.getTopAnchorPoint()[1]);

7" tablet is taking 10" layout

I have a problem with device picking wrong layout.
I have defined my layouts as per the screen size and grouped them under following -
layout-sw600dp, layout-sw720dp and layout-sw480dp.
I have two 7" tablets for sw600dp.
1- Samsung 7" galaxy tab - This device is taking correct layout as those defined in layout-sw600dp.
2- Another 7" device [ordered from a distributor in China]- This one is taking 10" layout.
When I use http://www.whatismyscreenresolution.com/ both the devices give 1024x600 .
To check I programmatically retrieved Smallest Screen Width and Screen Width [getResources().getConfiguration().smallestScreenWidthDp and screenWidthDp]. On 2nd device I get values as 720 and 1024.
Any idea as how can I proceed further to make sure that my second device also takes layouts defined under layout-sw600dp .
regards
Pradeep
what does this code returns on that device ?
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String pxSize = dm.widthPixels + " x " + dm.heightPixels;
it may show 720x1024.
that's because even if the screen has a physic size of 600x1024px, what you get from those methods are values set by manufacturers. There is possibly a difference between those set values and real values.
If this is the case, there no much you can do about it.
except may be
if ( "aTargetManufacturer".equals( android.os.Build.MANUFACTURER ) )
{
useAnotherLayout();
}
but that's clearly not good practice.

Resources