top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Android: LayoutParams constructor overload with size in dip?

+2 votes
277 views

In Android SDK there isn't an overload of a constructor of ViewGroup (and subclasses) with possibilities to specify the width and height in DP (or DIP) instead of in pixel. Why? Actually we have:

ViewGroup.LayoutParams(int width, int height)

Could be a good idea to have:

ViewGroup.LayoutParams(int dpWidth, int dpHeight, int ComplexUnitType.Dip) 
where ComplexUnitType could be an enum with units of measurement (for e.g) 
posted Jun 30, 2015 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+5 votes

I am using a linear layout and I want to position my EditText in center and linear layout full width.
This is my code,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:background="#eeeeee">

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="50px"
    android:background="#666666">

        <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/newEvent"
        android:hint="Enter the Name of Event"
        android:layout_below="@+id/textView2"
        android:layout_alignParentStart="true" />

    </LinearLayout>
</RelativeLayout>
0 votes

According to CDD document, it is stated below"Device implementations MUST have at least 340MB of memory available to the kernel and userspace. The 340MB MUST be in addition to any memory dedicated to hardware components such as radio, video, and so on that is not under the kernel's control."

MY understanding:
340 MB is required for both user and kernel space. 340 MB is for hardware components , So, in total minimum 680 MB (Please correct me if my understanding is wrong ?)

But, if i look at mobiles that are available in the market, they are not compliance with the requirement. (HTC ONE V , has 512 MB of RAM, but still runs android 4.0.3 , in which the requirement is 680MB.)

Considering above, how the OEM vendor passes compatibility test?

+2 votes

I wonder if it is possible to get the logcat output along with timestamp?
If so, how can i get it?

+3 votes

It appears that Locale.java in master (https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/java/util/Locale.java) now supports BCP-47, including script names. Does this mean that with the next Android version ("L"?) I will be able to create and use locales like "bs_Latn_BA" or "bs_Cyrl_BA"?

I am currently running KitKat and I don't see a system property that will persist the script part of the locale name. We have just:
/data/property/persist.sys.country
/data/property/persist.sys.language

I have tried to set the language property to include the script part (setprop persist.sys.language bs_Cyrl), and the value gets stored, but the script part is apparently ignored. If I set the language to bs_Cyrl and the country to BA, I get my dates/times/numbers etc. formatted with Latin values, not Cyrillic (bs_Latn_BA).

Am I correct in concluding that KitKat does not support locale names that include script parts, but that L will (might)? And that it will presumably have a new persistent property that will store the script?

...