0

I have Relative layout to which i want to set width 1.4dp

How to do that.. If any have any idea please help.

Thanks in advance...!

Noby
  • 6,562
  • 9
  • 40
  • 63

2 Answers2

3

According to this reference you can use decimal places for views:

android:layout_height and android:layout_width - May be a dimension value, which is a floating point number appended with a unit such as "14.5sp".

http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#attr_android:layout_height

ailtd
  • 43
  • 5
-1

you can only give integer values to layout parameters

source : http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html

No matter what the layout is you can never give a float value.

“dip” or “dp” or “dps” - Density-independent Pixels my friend which means you can't divide a fraction into another fraction.

pixels = dps * (density / 160).

For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels.

Arun Paarthi
  • 633
  • 7
  • 23
  • 4
    This comment is wrong. The LayoutParams methods involving size are in PIXEL units, which is why they are ints. Layout values can and are specified in float units (e.g. 1.6dp). – Mark Renouf Mar 03 '14 at 20:25