2017-09-09 11 views
0

我有一些问题,在我的布局宽度编辑文本在Android中,我如何展开EditText直到它遇到一些视图?

这里是描述我的问题

1.正常布局的截图(所有的意见都是的LinearLayout内)

enter image description here

2.当用户在编辑文本中输入很多文本行时,我想要下面的布局

enter image description here

3.但是,当用户输入多个文本行..我的布局看起来像下面。

enter image description here

我想编辑文本应该被拉伸,直到只有ImageView的满足底部的ViewGroup。

但是,更多输入文本行,更多正在增加编辑文本的高度,所以我看不到图像视图。

如果你给我任何解决方案,我会很感激。

+0

为LinearLayout中检查权重。 – Raghunandan

回答

0

LinearLayout处理这种布局很好。您可以使用LinearLayout中的属性android:layout_weight="1"设置您希望对象占用的空间的优先级。

的官方文档最好的形容: developer.android.com

+0

,高度为0dp .. – Doomsknight

0

采取的RelativeLayout为您的父母布局

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="?actionBarSize" 
     android:orientation="vertical"> 

     <EditText 
     android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.9" 
     android:inputType="textMultiLine" 
     android:scrollbars="vertical"/> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_marginBottom="?actionBarSize" 
     android:layout_width="match_parent" 
     android:layout_weight="0.1" 
     android:layout_height="?actionBarSize" /> 
    </LinearLayout> 

    <View 
     android:id="@+id/view1" 
     android:layout_width="match_parent" 
     android:layout_height="?actionBarSize" 
     android:layout_alignParentBottom="true" /> 
0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/bottomGroup" 
     android:orientation="vertical"> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 

    <RelativeLayout 
     android:id="@+id/bottomGroup" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" /> 

</RelativeLayout> 
相关问题