EditText
フィールドはスクロールビュー内のLinearLayout
にあります。 ScrollView
が存在しない限り、layout_weight="1.0"
は私のEditText
が残りの画面を占有できるようにします。しかし、ScrollView
内でLinearLayoutをラップすると、EditText
が1行に変更され、layout_weightは機能しません。スクロールビュー内で編集テキストを全画面で表示させる
私の完全なレイアウトファイル
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" >
<TextView android:id="@+id/titleTextView"
style="@style/TitleHeaderBarText"
android:text="@string/announcement" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="right" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Subject:"
android:textSize="16sp" />
<EditText
android:id="@+id/et_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Announcement:"
android:textSize="16sp" />
<EditText
android:id="@+id/et_announcement"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" />
<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="24sp"
android:paddingRight="24dp"
android:text="Save" />
</LinearLayout>
</ScrollView>
</LinearLayout>
私は私が間違っているのかを理解していないようです。どのようにLinearLayout
内の画面の残りの部分を占めるようにEditTextを取得するかについての提案は、ScrollView
です。
ありがとうございます。
EDIT これも私のレイアウトです。あなたはScrollViewを追加する必要が
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/titleTextView"
style="@style/TitleHeaderBarText"
android:text="@string/login_title" />
<ScrollView
android:id="@+id/sv_weight_tell_us"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@drawable/bg_light_radial_pink" >
<LinearLayout
android:layout_width="match_parent" android:layout_height="match_parent"
android:padding="12dp"
android:orientation="vertical" >
<TextView
android:id="@+id/login_header"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="Login" />
<TableLayout
android:layout_width="match_parent" android:layout_height="wrap_content"
android:stretchColumns="1" >
<TableRow>
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:paddingRight="20dp"
android:text="@string/username" />
<EditText
android:id="@+id/et_username"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/password" />
<EditText
android:id="@+id/et_password"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:inputType="textPassword" />
</TableRow>
<TableRow>
<View/>
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/login"
android:padding="12dp" />
</TableRow>
</TableLayout>
<ProgressBar
android:id="@+id/pb_1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true"
style="?android:attr/progressBarStyleSmall"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_weight="1.0" android:gravity="bottom"
android:text="@string/dont_have_Q" />
<TextView
android:id="@+id/tv_sign_up"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/sign_up_" />
</LinearLayout>
</ScrollView>
</LinearLayout>
のEditTextはlayout_weight属性を持っている必要がありますか? LinearLayoutのwidthがmatch_parentに設定されている場合、EditTextをmatch_parentに設定すると、方向が「垂直」なので、画面がいっぱいになります。 – hooked82
ありがとうございます。それは私があまりにも思っていて、ここに投稿する前に試したものです。しかし、それはうまくいかなかった。 – achie
レイアウトファイルをもう一度見て、オープニングタグが見つからないことがわかります。これはあなたの実際のレイアウトxmlにも欠けていますか? –
hooked82