這是一種延續,我想在離線時在屏幕底部(在底部工具欄下方)獲取警告文本。當在脫機模式下看起來是正確的:Android製作底部工具欄不能移動到佈局頂部
然而,當我隱藏離線模式下,它會彈出佈局的頂部,像這樣的(我想顯示隱藏的一切):
我試着將底部工具欄設置爲android:layout_alignParentBottom="true"
,當我隱藏帶有TextView的RelativeLayout(離線模式)時,它不會彈出到頂部,但是當我不隱藏離線模式時,它們會相互覆蓋。
也許很容易的人多一點經驗與Android UI比我的XML佈局目前看起來是這樣的:
<RelativeLayout
android:id="@+id/mainLyt"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/formScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/bottomBar" >
<LinearLayout
android:id="@+id/formLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="15dp"
android:paddingRight="10dp"
android:paddingBottom="15dp"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/bottomBar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_above="@+id/bottomOffline"
android:background="@color/form_toolbar">
<ImageButton
android:id="@+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="btnPrevClicked"
android:layout_alignParentLeft="true"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/toolbar_prev"
android:padding ="8dp"
/>
<ImageButton
android:id="@+id/btnIndex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btnPrev"
android:onClick="btnIndexClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/toolbar_index"
android:padding ="8dp"
/>
<ImageButton
android:id="@+id/btnValidation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btnIndex"
android:onClick="btnValidationClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/toolbar_validate"
android:padding ="8dp"
/>
<ImageButton
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="btnNextClicked"
android:focusableInTouchMode="false"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/toolbar_next"
android:padding ="8dp"
/>
<!-- Some Buttons -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/bottomOffline"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_alignParentBottom="true"
android:background="@color/orangelight"
android:gravity="center_horizontal">
<TextView
android:id="@+id/offline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:text="OFFLINE MODE"
android:textStyle="bold"
android:textColor="@color/white"
android:padding ="8dp"
/>
</RelativeLayout>
</RelativeLayout>
謝謝!
更好 - 現在我可以看到其餘的字段,但它仍然彈出到頂部...並且「離線模式」根本不顯示...當處於離線模式時 –
whops,設置LinearLayout的高度到「wrap_content」 – leibreichb1
太棒了。那就是訣竅。我需要查看「wrap_content」和「parent_match」之間的區別。但它像一種魅力。 –