top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Android layout size

+5 votes
291 views

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>
posted Aug 12, 2016 by Tina

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

First to make Linear layout full width you have remove the android:paddingLeft and android:paddingRight. Then about centering the EditText in Linear layout, I would not recommend using Linear layout. You could directly place EditText in relative layout and set android:layout_centerInParent="true".

Hope this helps!

answer Aug 15, 2016 by Vinod Kumar K V
Similar Questions
+3 votes

I am receiving "Fatal error", if I change the layout.xml. It is that I am just swapping two elements, before swapping they work fine. After swapping, I am facing error. Help!

+2 votes

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) 
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?

...