Android的底层制作工具栏不会移动到布局的俯视 [英] Android making bottom tool bar not move to top of layout

查看:182
本文介绍了Android的底层制作工具栏不会移动到布局的俯视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是形式的延续,在这里我想下线的时候让(我下面的底部工具栏)在我的屏幕底部的警告文字。当在脱机模式下看起来是正确的:

This is sort of a continuation of , where I wanted to get a warning text at the bottom of my screen (below my bottom tool bar) when off line. When in offline mode looks correct:

然而,当我隐藏离线模式下它弹出来布局的顶部,喜欢这类(隐藏一切,我想显示):

However when I hide the offline mode it pops to the top of the layout, like such (hiding everything I want to show):

我试过底部工具栏设置为的android:layout_alignParentBottom =真正的,这并从弹出顶端保持它,当我隐藏的RelativeLayout与TextView的中它(离线模式),但他们彼此叠加的时候,我不隐藏离线模式。

I tried setting the bottom tool bar to android:layout_alignParentBottom="true", that does keep it from popping to the top when I hide the RelativeLayout with the TextView in it (Offline Mode) but then they overlay each other when I do not hide the Offline Mode.

大概为方便更多的人使用Android的UI有点经验比我的XML布局目前看起来是这样的:

Probably easy for someone a bit more experienced with Android UI than I. The XML layout currently looks like this:

<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>

谢谢!

推荐答案

尝试包裹在的LinearLayout底部的观点,并从两个嵌套观点删除对齐领域

Try wrapping the bottom views in a LinearLayout and remove the align fields from the two nested views

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">

<RelativeLayout
    android:id="@+id/bottomBar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    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: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>

这篇关于Android的底层制作工具栏不会移动到布局的俯视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆