Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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 与上面的EditText相比,EditText宽度更长_Android - Fatal编程技术网

Android 与上面的EditText相比,EditText宽度更长

Android 与上面的EditText相比,EditText宽度更长,android,Android,我有一个包含一个AutoCompleteTextView和一个EditText的活动。edittext通过xml文件禁用,但与未禁用的AutoCompleteTextView相比,宽度更长。为什么?这是第二版文本的xml代码。请帮助 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layo

我有一个包含一个AutoCompleteTextView和一个EditText的活动。edittext通过xml文件禁用,但与未禁用的AutoCompleteTextView相比,宽度更长。为什么?这是第二版文本的xml代码。请帮助

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip"
android:gravity="right"> 

<TextView
    android:id="@+id/cusNameTV"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/customerName"
    android:textColor="#FFFFFF" 
    android:layout_gravity="right"
    />

<AutoCompleteTextView
    android:id="@+id/cusName_CB"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

<TextView
    android:id="@+id/cusaddrTV"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/cusaddress"
    android:textColor="#FFFFFF"
    android:layout_marginBottom="5dip"
    android:layout_marginTop="5dip" 
    android:layout_gravity="right"/>


<EditText
    android:id="@+id/editText_cusAddress"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/darker_gray"
    android:clickable="false"
    android:cursorVisible="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:inputType="none"
    android:state_enabled="false"/>

</LinearLayout>



根据您的XML,
EditText
背景为灰色,没有边框。但是
AutoCompleteTextView
没有背景色。因此,您有了
自动完成文本视图的边框线。这使您的
AutoCompleteTextView
看起来比
EditText

我已经给了两个视图的背景色,现在看起来是一样的

边界线只会把你弄糊涂

比较如下:

XML的布局是


编辑的布局是

我在这里只能看到一个编辑文本..很抱歉,我已经编辑了我的评论。需要注意的一点是,当我删除
android:background=“@android:color/dark\u gray”时
宽度等于上述宽度。我不想编辑我的UI设计。你能帮我做一下目前的设计吗?我会很感激的。事实上,这是另一种方式。编辑文本看起来很孤独,然后是自动完成小部件。我认为这与背景色有关。这是一个图像,即@android:color/darker\u gray。顺便说一下,我在android颜色文件夹中没有看到较深的灰色。我是否遗漏了一些内容?在emu上查看UI时,您所提到的内容是正确的。但在三星GT I8150上。我明白这个问题。我如何上传用户界面的截图,以便您更好地了解这个问题
 <RelativeLayout 
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:id="@+id/main"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">

    <TextView
         android:id="@+id/host_label"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_below="@+id/home"
         android:paddingTop="0dp"
         android:paddingLeft="15dp"
         android:textSize="25sp"
         android:textColor="#a5d4e2"
        android:text="host"
         android:textStyle="normal"
        />
  <TextView
     android:id="@+id/port_label"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_below="@+id/home"
     android:layout_toRightOf="@+id/host_input"
     android:paddingTop="0dp"
     android:textSize="25sp"
     android:textColor="#a5d4e2"
     android:text="port"
     android:textStyle="normal"  />

    <EditText 
          android:id="@+id/host_input" 
          android:inputType="textEmailAddress"
         android:layout_width="172dp" 
         android:layout_height="wrap_content" 
         android:background="@android:drawable/editbox_background"
         android:layout_below="@id/host_label"
         android:layout_marginTop="4dp" 
         android:layout_marginLeft="15dp" 
         android:layout_marginRight="15dp"  />

      <EditText 
        android:id="@+id/port_input" 
        android:inputType="number"
        android:layout_width="100dp" 
        android:layout_height="wrap_content" 
        android:background="@android:drawable/editbox_background"
        android:layout_below="@id/host_label"
        android:layout_toRightOf="@id/host_input"
        android:layout_marginTop="4dp"/>

    <TextView
        android:id="@+id/username_label"
        android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/host_input"
       android:paddingTop="15dp"
       android:paddingLeft="15dp"
       android:textSize="25sp"
        android:textColor="#a5d4e2"
       android:text="username"
       android:textStyle="normal"/>

        <EditText 
            android:id="@+id/username_input" 
           android:inputType="textEmailAddress"
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content" 
           android:background="@android:drawable/editbox_background"
           android:layout_below="@id/username_label"
           android:layout_marginTop="4dp" 
           android:layout_marginLeft="15dp" 
          android:layout_marginRight="15dp" 
   />