• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Text boxes wont apply padding

Welton122

Lurker
Hello,

I'm new to android so u may have to bear with me.

When im creating the graphical user interface and apply padding (10dp) to the left and right sides of the email text box the padding dosent actually apply. Here are the current settings.

Code:
<EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" 
        android:paddingLeft="10dp" >
        <requestFocus />
    </EditText>

Basically i was the text box to fill the screen (width wise not the height) but have a 10dp gap on the left and right hand sides to make it look cleaner.

Can anyone help me with this please?

Thanks,
Jake
 
I've moved this to out Application Development forum so our coders could get a look.:)
 
Ok, I'm new too... But I'm sure your using padding wrong... If you want the text box to fill the width you should do it like this...

<EditText
android:id="@+id/editText1"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textEmailAddress"
>
<requestFocus />
</EditText>

Set the (android:layout_width="fill_parent") to (android:layout_width="300dp") like I did it above... Now like I said, I'm also new to this, There could be a better way. But I just published my first app, and I used this method with buttons. And it seems to work for all screen sizes...
 
I think padding would apply to text i.e. text in the EditText would be padded by 10dip. If you want to the EditBox to move 10dip to left you need to use layout margin. To fill do what @kodiak211 says use fill_parent
 
Back
Top Bottom