我在Android Studio中製作一個簡單的佈局是這樣的:滾動型不能顯示的最後一個元素
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="hisoka.poipo.com.wishtleblower.KorupsiActivity"
android:scrollIndicators="right"
android:fillViewport="true"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0FFFF"
android:layout_marginTop="@dimen/topMargin"
android:layout_marginBottom="@dimen/bottomMargin"
android:layout_marginLeft="@dimen/leftMargin"
android:layout_marginRight="@dimen/rightMargin"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Keterangan :"
android:textStyle="bold"
android:layout_centerInParent="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:inputType="textMultiLine"
android:ems="10"
android:background="@drawable/box"
android:id="@+id/ket_et" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B0E0E6"
android:layout_marginTop="@dimen/topMargin"
android:layout_marginBottom="@dimen/bottomMargin"
android:layout_marginLeft="@dimen/leftMargin"
android:layout_marginRight="@dimen/rightMargin"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Terduga :"
android:layout_weight="1"
android:textStyle="bold"
android:layout_margin="4dip"
/>
<TextView
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Nama :"
android:layout_weight="1"
android:layout_margin="4dip"
android:layout_width="wrap_content"
/>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/box"
android:layout_margin="4dip"
android:layout_width="match_parent"
/>
<TextView
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Jabatan :"
android:layout_weight="1"
android:layout_margin="4dip"
android:layout_width="wrap_content"
/>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/box"
android:layout_margin="4dip"
android:layout_width="match_parent"
/>
<TextView
android:gravity="center_vertical"
android:text="Klasifikasi Jabatan :"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<Spinner
android:id="@+id/korupsiSpinnera"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Nama :"
android:layout_weight="1"
android:layout_margin="4dip"
android:layout_width="wrap_content"
/>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/box"
android:layout_margin="4dip"
android:layout_width="match_parent"
/>
<TextView
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Jabatan :"
android:layout_weight="1"
android:layout_margin="4dip"
android:layout_width="wrap_content"
/>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/box"
android:layout_margin="4dip"
android:layout_width="match_parent"
/>
<TextView
android:gravity="center_vertical"
android:text="Klasifikasi Jabatan :"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<Spinner
android:id="@+id/korupsiSpinnerb"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B0E0E6"
android:layout_marginTop="@dimen/topMargin"
android:layout_marginLeft="@dimen/leftMargin"
android:layout_marginRight="@dimen/rightMargin"
android:orientation="vertical">
<TextView
android:gravity="center_vertical"
android:text="Lampiran :"
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Nama File "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Rfounder "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Keterangan "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="CEO "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Size "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="36 KB "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Delete "
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="X"
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="Add File"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B0E0E6"
android:layout_marginTop="@dimen/topMargin"
android:layout_marginBottom="@dimen/bottomMargin"
android:layout_marginLeft="@dimen/leftMargin"
android:layout_marginRight="@dimen/rightMargin"
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:gravity="center_vertical"
android:text="Kirim Laporan"
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<TextView
android:gravity="center_vertical"
android:text="Captcha"
android:textStyle="bold"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:layout_margin="4dip"
android:layout_weight="1"
android:layout_width="wrap_content"
/>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/box"
android:layout_margin="4dip"
android:layout_width="wrap_content"
android:ems="7"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New CheckBox"
android:id="@+id/checkBox"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="Submit"
android:gravity="bottom"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
在Android Studio中,我可以看到就在那裏,去年元素,如下圖所示: 但是,當我我真正的設備上運行它,最後一個元素不能正常顯示,我的最後一個按鈕丟失:
我瞪大眼睛了一些網頁,並表示只需添加
android:fillViewport="true"
scrolView ..但這不能解決我的問題....我已經添加了另一個XML標籤,但仍然沒有... 任何想法...... ????
非常感謝你...... :)
嘗試刪除android:layout_gravity =結束我認爲它不需要 – Jois
嘗試給填充滾動視圖到底部... –
我需要layout_gravity =結束先生Jois ... :) –