English 中文(简体)
EditText获胜t 填补剩余的空间
原标题:EditText wont fill up the remaining space

因此,我有这份“To”文本,是供联系人参考的斜体,还有一个搜索塔,以寻找所有线上的接触。 文本概览和纽伦都是好的,但问题在于斜体是小的,希望它占据所有剩余的空间。 该法典:

<RelativeLayout  
        android:layout_height="wrap_content"  
        android:layout_width="fill_parent"
        android:paddingTop="10dp">
        <TextView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="To: "
            android:textColor="#000000"
            android:paddingTop="10dp"
            android:layout_toLeftOf="@+id/editText_recipient"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"/> 
        <EditText
            android:id="@+id/editText_recipient"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"   
            android:hint="Enter Number"  
            android:inputType="number"
            android:textSize="12sp"
            android:layout_toLeftOf="@+id/button_recipient_picker"  
            android:layout_marginLeft="5dp"/>
        <Button  
            android:id="@+id/button_recipient_picker" 
            android:layout_height="wrap_content"   
            android:layout_width="wrap_content"  
            android:text="Browse .."  
            android:layout_alignParentRight="true" 
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:onClick="doLaunchContactPicker"/>
        </RelativeLayout>
最佳回答
<LinearLayout  
        android:layout_height="wrap_content"  
        android:layout_width="fill_parent"
        android:paddingTop="10dp">
        <TextView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="To: "
            android:textColor="#000000"
            android:paddingTop="10dp"
            android:layout_marginLeft="10dp"/> 
        <EditText
            android:id="@+id/editText_recipient"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"   
            android:hint="Enter Number"  
            android:inputType="number"
            android:textSize="12sp"
            android:layout_marginLeft="5dp"
            android:layout_weight="1"
         />
        <Button  
            android:id="@+id/button_recipient_picker" 
            android:layout_height="wrap_content"   
            android:layout_width="wrap_content"  
            android:text="Browse .."  
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:onClick="doLaunchContactPicker"/>
        </LinearLayout>

使用这种布局,即把你的布局改为线性(横向违约)。 并且加上一个排外-对倾斜,它将占用剩余的空间。

问题回答

For those who need an answer to this and to resolve this post without giving an alternative, the answer is fairly simple. You need to tell every control where to position according to each other and apply to the control which should take available space android:layout_width = "match_parent" even though in a LinearLayout, this would push every other control aligned out of the screen, in a RelativeLayout it works perfectly

<RelativeLayout  
    android:layout_height="wrap_content"  
    android:layout_width="match_parent"
    android:paddingTop="10dp">
    <TextView  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="To: "
        android:textColor="#000000"
        android:paddingTop="10dp"
        android:layout_toLeftOf="@+id/editText_recipient"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"/> 
    <EditText
        android:id="@+id/editText_recipient"
        android:layout_height="wrap_content"
        android:layout_width="MATCH_PARENT"
        android:hint="Enter number"  
        android:inputType="number"
        android:textSize="12sp"
        android:layout_toLeftOf="@+id/button_recipient_picker"  
        android:layout_marginLeft="5dp"/>
    <Button  
        android:id="@+id/button_recipient_picker" 
        android:layout_height="wrap_content"   
        android:layout_width="wrap_content"  
        android:text="Browse .."  
        android:layout_alignParentRight="true" 
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:onClick="doLaunchContactPicker"/>
    </RelativeLayout>




相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签