这是一种延续,我想在离线时在屏幕底部(在底部工具栏下方)获取警告文本。当在脱机模式下看起来是正确的: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”之间的区别。但它像一种魅力。 –