保证金在Android上编辑文本中 [英] margin inside the edit text in android

查看:192
本文介绍了保证金在Android上编辑文本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:我有一个EditText,我想设置的EditText内的保证金,我的意思是,余量为编辑文本的内容(文本),而不是保证金的视图女巫,我可以通过这个属性解析:机器人:layout_marginLeft

My question is : I have an EditText and I want set a margin inside the EditText, I mean margin for the content (the text) of the edit text, not a margin for a the view witch I can resolve by this attribute : android:layout_marginLeft.

我需要让一些空间,前后的EditText内的文本之后。

I need let some space before and after the text inside the EditText.

我试图设置填充,但是还是不行!

I tried to set the padding, but doesn't work !

这是我的XML code:

this is my xml code :

<FrameLayout
    android:layout_width="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" 
    android:layout_marginLeft="2dp">

    <EditText android:inputType="none"
        android:textSize="15sp" 
        android:id="@+id/editText1" 
        android:scrollHorizontally="true" 
        android:layout_height="35dp"  
        android:padding="3dip" 
        android:singleLine="true"
        android:layout_width="160dp" 
        android:layout_weight="0" />

    <ImageView android:id="@+id/refreshButton" 
        android:src="@drawable/refresh" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"
        android:layout_gravity="center_vertical|right" />
</FrameLayout>

任何一个可以帮助我做到这一点?

Can any one help me to do that?

在此先感谢

推荐答案

在填充变量应该是正是你所期待的。你应该尽量增加填充到类似10dp只是为了测试,如果它做任何事情。我猜测,因为EditText上的背景是9修补填充不是演戏,你会如何期待。当您在一个视图与9补丁设置填充的背景下,内置的9补丁是不是忽略任何填充。因此,如果9补丁有5DP填充和设置3DP填充在XML中,你不会得到8DP填充,你会得到3DP。

The padding variable should be exactly what you are looking for. You should try to increase the padding to something like 10dp just to test if it does anything. I'm guessing that because the background of the EditText is a 9 patch the padding is not acting how you would expect. When you set padding on a view with a 9 patch as the background any padding that is built into the 9 patch is than ignored. So if the 9 patch has 5dp padding and you set 3dp padding in the xml you will not get 8dp padding you will get 3dp.

这篇关于保证金在Android上编辑文本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆