Value equals to match_parent or fill_parent in dimens.xml?

Use this, it works for me <dimen name=”custom_wrap_content”>-2px</dimen> <dimen name=”horizontal_border_height”>@dimen /custom_wrap_content</dimen> <dimen name=”custom_match_parent”>-1px</dimen> <dimen name=”vertical_border_height”>@dimen /custom_match_parent</dimen> And the Reason why match_parent doesn’t run. You cannot supply a build in keyword like match_parent Edit: Use px instead of dp as suggested by Jarett Millard in the comments.

Inconsistency when setting TextView font size in code and in resources

You should use setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); because the documentation of the getDimension method states that it returns a Resource dimension value multiplied by the appropriate metric. which I understand to be the precalculated absolute px value. That is, use: tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.text_size_small));

1D Number Array Clustering

Don’t use multidimensional clustering algorithms for a one-dimensional problem. A single dimension is much more special than you naively think, because you can actually sort it, which makes things a lot easier. In fact, it is usually not even called clustering, but e.g. segmentation or natural breaks optimization. You might want to look at Jenks …

Read more

Load dimension value from res/values/dimension.xml from source code

In my dimens.xml I have <dimen name=”test”>48dp</dimen> In code If I do int valueInPixels = (int) getResources().getDimension(R.dimen.test) this will return 72 which as docs state is multiplied by density of current phone (48dp x 1.5 in my case) exactly as docs state : Retrieve a dimensional for a particular resource ID. Unit conversions are based …

Read more