我的EditText中有数百行文本,我的编辑文本的高度设置为match_parent
,但是,只有几行代码可见,使屏幕的其余部分为空。如何使文本填充我的编辑文本?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/vector"
android:orientation="vertical" >
<EditText
android:id="@+id/ed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button2"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:background="#50dddddd"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="5"
android:maxWidth="5.0dip"
android:minWidth="10.0dip"
android:scrollHorizontally="false"
android:textColor="#424242"
android:textStyle="bold" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Write File to Application SandBox"
android:visibility="gone" />
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Read File from Application SandBox"
android:visibility="gone" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:background="@drawable/antivirus_btn2"
android:text=" READ "
android:textColor="@drawable/antivirus_btn_text2" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:background="@drawable/antivirus_btn3"
android:text=" SAVE "
android:textColor="@drawable/antivirus_btn_text3" />
答案 0 :(得分:0)
使用LinearLayout而不是RelativeLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/vector"
android:orientation="vertical" >
<EditText
android:id="@+id/ed"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:layout_margin="5dp"
android:background="#50dddddd"
android:gravity="top|left"
android:inputType="textMultiLine"
android:textColor="#424242"
android:textStyle="bold" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1";
android:text="Write File to Application SandBox"
android:visibility="gone" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1";
android:text="Read File from Application SandBox"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1";
android:layout_margin="5dp"
android:background="@drawable/antivirus_btn2"
android:text=" READ "
android:textColor="@drawable/antivirus_btn_text2" />
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1";
android:layout_margin="5dp"
android:background="@drawable/antivirus_btn3"
android:text=" SAVE "
android:textColor="@drawable/antivirus_btn_text3" />
</LinearLayout>
</LinearLayout>
答案 1 :(得分:0)
如果仔细观察,您的EditText的高度为wrap_content
,而不是match_parent
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/vector"
android:orientation="vertical" >
<EditText
android:id="@+id/ed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
您需要将其修改为match_parent
或fill_parent
。