在底部带有editText的LinearLayout覆盖了scrollView的内容,该内容以编程方式填充。 怎么避免这个? 我在这个消息的第一个版本中简化了XML。 我现在已经添加了完整的代码
我想保持我的editText高度可扩展。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/backNormal"
android:orientation="vertical"
>
<include layout="@layout/adview"
android:layout_alignParentTop="true"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:background="@color/back1"
android:layout_below="@+id/adView"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:id="@+id/textChatSubjectTitle"
android:text='Subject'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_weight="5"
android:layout_height="wrap_content"
android:textColor="@color/text1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:orientation="horizontal"
>
<TextView
android:id="@+id/textChatActn"
android:text='0'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/textWhite"
android:background="@color/gray"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:id="@+id/textChatUsers"
android:text='users'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/darkGray"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageChatImageTitle"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="right"
/>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollChat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/backNormal"
android:orientation="vertical"
android:layout_below="@+id/top"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/back1"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
>
<ImageView
android:id="@+id/buttonClip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:src="@drawable/clip32"
android:layout_weight="1"
android:layout_gravity= "center_vertical|center_horizontal"
/>
<EditText
android:id="@+id/editChatMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine|textCapSentences"
android:minLines="1"
android:gravity="top|left"
android:maxLines="5"
android:maxLength="500"
android:layout_marginRight="5dp"
android:text=''
android:layout_gravity= "center_vertical|center_horizontal"
android:textColor="@color/text1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="5"
android:background="@drawable/edit"
android:scrollHorizontally="false"
android:cursorVisible="true"
android:textCursorDrawable="@null"
/>
<Button
android:id="@+id/buttonChatSend"
android:text='>'
android:layout_marginRight="5dp"
android:gravity="center"
android:layout_gravity= "center_vertical|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/darkGray"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:background="@drawable/button_normal"
/>
</LinearLayout>
</RelativeLayout>
有什么想法吗? 谢谢!
答案 0 :(得分:0)
我建议使用相对布局作为父级。然后添加上面的规则。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/llButton"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/llButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:id="@+id/editMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="top|left"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:scrollHorizontally="false" />
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text='send'
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
答案 1 :(得分:0)
Please try the below code, if it solves your problem.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="1200dp"
android:background="#ff0000"
android:orientation="vertical"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/editMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@drawable/edit"
android:gravity="top|left"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:textColor="@color/text1"
android:scrollHorizontally="false"
/>
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@drawable/button_normal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</ScrollView>