Arkaha
Arkaha

Reputation: 1612

android displayed layout with cutted EditText

I faced with such problem, different paint of the same xml layout on same screen sizes, there are two images, first is eclipse ADT layout paint, and second is emulator layout paint.

alt text alt text

My questions:

  1. Why it so different?

  2. How to create normal textfields which are not cutted(on both images)?

layout xml:

<?xml version="1.0" encoding= "utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent" android:layout_height="fill_parent"
       android:orientation="vertical" android:gravity= "center"
       android:layout_weight="1" >
       <LinearLayout android:orientation="horizontal"
             android:layout_width="fill_parent" android:layout_height="fill_parent"
             android:layout_weight="0.33" >
       </LinearLayout>
       <LinearLayout android:orientation="vertical"
             android:layout_width="fill_parent" android:layout_height="fill_parent"
             android:layout_weight="0.33" android:gravity= "center">
             <TextView android:text="@string/entertitle" android:id="@+id/EnterTitle"
                   android:gravity="center" android:layout_width="wrap_content"
                   android:layout_height="wrap_content" android:textStyle="bold" ></TextView>
             <LinearLayout android:layout_width="fill_parent"
                   android:layout_height="fill_parent" android:layout_weight="1"
                   android:orientation="horizontal" android:gravity="center" >

                   <LinearLayout android:layout_width="wrap_content"
                         android:layout_height="fill_parent" android:layout_weight="0.3"
                         android:orientation="vertical" android:gravity="center" >

                         <TextView android:text="@string/yourlogin" android:id="@+id/YourLogin"
                               android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth='150dp' ></TextView>
                         <TextView android:text="@string/password" android:id="@+id/YourPass"
                               android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth='150dp' ></TextView>
                   </LinearLayout>
                   <LinearLayout android:layout_width="fill_parent"
                         android:layout_height="fill_parent" android:layout_weight="0.7"
                         android:orientation="vertical" android:gravity="center" >
                         <EditText android:text="" android:id="@+id/EditLogin"
                               android:layout_width="wrap_content" android:layout_height="wrap_content"
                               android:minWidth='150dp' android:gravity="right" ></EditText>

                         <EditText android:text="" android:id="@+id/EditPass"
                               android:layout_width="wrap_content" android:layout_height="wrap_content"
                               android:gravity="right" android:minWidth='150dp' ></EditText>
                   </LinearLayout>
             </LinearLayout>
             <LinearLayout android:layout_width="fill_parent"
                   android:layout_height="fill_parent" android:layout_weight="1"
                   android:orientation="horizontal" android:gravity="center" >
                   <CheckBox android:text="@string/saveauth" android:id="@+id/CheckSavePass"
                         android:layout_width="wrap_content" android:layout_height="wrap_content" ></CheckBox>
                   <Button android:text="@string/entertitle" android:id="@+id/ButtonEnter"
                         android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>

             </LinearLayout>
       </LinearLayout>
       <LinearLayout android:orientation="horizontal"
             android:layout_width="fill_parent" android:layout_height="fill_parent"
             android:layout_weight="0.33" >
       </LinearLayout>



</LinearLayout>

Upvotes: 0

Views: 505

Answers (3)

Sujanian
Sujanian

Reputation: 55

Try this one:

`

<TableRow> 
    <TextView 
        android:text="PASSWORD"
        android:layout_width ="120px"
        />
    <EditText 
        android:id="@+id/pwd" 
        android:layout_width="50px" />
</TableRow> `

Upvotes: 0

Sheldon Rong
Sheldon Rong

Reputation: 1506

I rescanned your XML, it seems that in the ADT layout paint view, both of your Textviews are not displayed competely, so when you run the emu, and you click the first button which makes it activated, the system seems to drag the view a little bit down, so that the first view is completely displayed, thus making the second one look weired.

Upvotes: 1

Sheldon Rong
Sheldon Rong

Reputation: 1506

yeah, I faced one similar problems before, I tried to set the TextView's alignment to right, so I put layout_gravity="right" in the xml file, and it shows exactly what I wanted in the ADT layout, yet when running on android, the text still aligned to the left...

The way I solved that problem is to put this view into a RelativeLayout and then use android:gravity="center_vertical|right" in the RelativeLayout tag.

It is hard to say this works in terms of your project, but you may want to give a try.

BTW: I have no idea why they look different, but I believe the results on emu is more real than the layout paint.

Upvotes: 1

Related Questions