我真的是Android編程的新手。我嘗試設計聊天佈局,但是我發現了一些佈局設計問題。爲什麼編輯文本佈局不能在橫向模式下自動拉伸?編輯文字橫向Android時不會自動拉伸
這裏是我的代碼:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/myappbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom">
<include
layout="@layout/input_message_area"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:gravity="bottom" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/myappbar"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginBottom="75dp"
android:background="#63DDEC"
android:paddingLeft="5dip"
android:paddingTop="0dip"
android:paddingRight="5dip"
android:paddingBottom="1dip">
<ListView
android:id="@+id/lv_chat_story"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:divider="@color/colorTransparent"
android:dividerHeight="0dp" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
,這是input_message_area.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#63DDEC"
android:gravity="bottom"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner_a"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="5dp"
android:padding="3dp">
<Button
android:id="@+id/buttonEmoji"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:background="@drawable/smile_center" />
<EditText
android:id="@+id/chat_edit_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:scrollHorizontally="false"
android:layout_toRightOf="@id/buttonEmoji"
android:hint="Type a message"
android:maxLines="4"
android:singleLine="false"
android:inputType="textCapSentences"
android:textSize="18sp"
android:paddingLeft="4dp"/>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/chat_edit_text1"
android:background="@drawable/camera_center"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_main"
android:layout_toRightOf="@id/inputLayout"
android:layout_alignBaseline="@+id/inputLayout"
android:layout_alignBottom="@+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="-10dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="@drawable/send_center"
app:backgroundTint="@color/colorPrimary"
app:layout_anchor="@id/inputLayout"
app:layout_anchorGravity="bottom|right" />
</LinearLayout>
謝謝。
感謝。這真的很有幫助。 –