当SearchView扩展时,其他视图布局会移动

时间:2018-06-08 09:29:38

标签: android layout searchview expand gravity

我有这种奇怪的行为我无法调试&固定。 我有我创建的这个(自定义)布局,它在右上角的屏幕角(它意味着居中)开始(不自觉)。

view before expanding searchview - top-right corner and not center

但是,当我点击(即展开)操作栏中的搜索视图(并从该点开始)时,布局会按预期为中心。

view after expanding searchview - centered

布局代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="75dp"
android:background="@color/colorBrighterGray"
tools:context=".MainActivity">

<RelativeLayout
    android:id="@+id/myRelativeLatyoutPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:orientation="vertical">

    <MyCustomView
        android:id="@+id/myCustomView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:gravity="center"
        android:background="@android:color/transparent" />

myCustomView是从右上角移动到中心的那个。

您能否指出我必须研究的任何方向? (我没有在我的布局中添加SearchView元素 - 我通过调用getSuuported来获得它...)

谢谢!

0 个答案:

没有答案