1

我有一个包含一个 AutoCompleteTextView 和一个 EditText 的活动。通过 xml 文件禁用了 edittext,但与未禁用的 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>
4

2 回答 2

0

根据您的 XML,EditText背景是灰色的,没有边框。但是AutoCompleteTextView没有背景颜色。所以你有边界线AutoCompleteTextView。这让你看起来AutoCompleteTextViewEditText.

我已经为这两个视图提供了背景颜色,现在看起来一样了。

边界线只会让你感到困惑。

比较如下:

你的 XML 布局是在此处输入图像描述

编辑后的布局是在此处输入图像描述

于 2012-08-04T10:03:42.643 回答
0
 <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" 
   />

于 2012-08-04T09:00:39.773 回答