Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中编辑文本内的边距_Android_Android Layout_Android Edittext_Margin_Textview - Fatal编程技术网

android中编辑文本内的边距

android中编辑文本内的边距,android,android-layout,android-edittext,margin,textview,Android,Android Layout,Android Edittext,Margin,Textview,我的问题是:我有一个EditText,我想在EditText内设置一个边距,我指的是编辑文本内容(文本)的边距,而不是我可以通过此属性解析的视图的边距:android:layout\u marginLeft 我需要在编辑文本前后留出一些空间 我试图设置填充物,但不起作用 这是我的xml代码: <FrameLayout android:layout_width="wrap_content" xmlns:android="http://schemas.android.com/a

我的问题是:我有一个EditText,我想在EditText内设置一个边距,我指的是编辑文本内容(文本)的边距,而不是我可以通过此属性解析的视图的边距:
android:layout\u marginLeft

我需要在编辑文本前后留出一些空间

我试图设置填充物,但不起作用

这是我的xml代码:

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

有人能帮我吗


提前感谢

padding变量应该正是您想要的。您应该尝试将填充增加到10dp,以测试它是否有任何作用。我猜,因为EditText的背景是一个9补丁,所以填充并不是你所期望的那样。在以9面片为背景的视图上设置填充时,9面片中内置的任何填充都将被忽略。因此,如果9补丁有5dp填充,而您在xml中设置了3dp填充,那么您将不会得到8dp填充,您将得到3dp。

请记住,这些天(2016年)这个答案有一个问题,即更改文本上的填充,而不对背景可绘制文件进行同样的操作。根据背景(例如AppCompat base EditText样式),其外观可能会很奇怪