小编Jam*_*mie的帖子

Android EditText不会占用剩余空间

在我的Android应用中,我有一个标签Activity.在其中一个标签中,我有两个TextViews和两个EditTexts.

第一个EditText只有一行,那没关系.不过,我想其他的EditText,android:id="@+id/paste_code",占用的剩余空间,但无论我做什么它,它会只显示一行.我不想手动设置行数,因为屏幕上适合的数字因设备而异.

这是相关的代码.它嵌套在选项卡的所有必要组件中Activity.

<ScrollView
    android:id="@+id/basicTab"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:layout_weight="1" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Paste title"
            android:layout_weight="0" />
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/paste_title_hint"
            android:id="@+id/paste_title"
            android:lines="1"
            android:gravity="top|left"
            android:layout_weight="0" />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Paste text"
            android:layout_weight="0" />
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:hint="@string/paste_hint"
            android:id="@+id/paste_code"
            android:gravity="top|left"
            android:layout_weight="1" />
    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
3909
查看次数

标签 统计

android ×1