避免布局中保证金调整改变 [英] Avoid layout to be resized on margin changed

查看:180
本文介绍了避免布局中保证金调整改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程改变的FrameLayout内布局的保证金。我的目标是让像Facebook应用滑动视图。是有可能避免这种布局调整大小?这是我的布局移动:

I'm programmatically changing the margin of a layout inside a framelayout. My goal is to make a sliding view like the Facebook app. Is it possible to avoid this layout to be resized? This is my layout moving:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="#00a2ff"
    android:gravity="center_vertical"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/left"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/ivGPSSearching"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:src="@drawable/actionbar_gps_searching" />
    </LinearLayout>

    <ImageView
        android:id="@+id/ivStarsFilter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:src="@drawable/actionbar_star" />
</LinearLayout>

我不想被调整左侧的LinearLayout。我希望你会明白我想要的:)

I don't want the left LinearLayout to be resized. I hope you will understand what I want :)

感谢

推荐答案

要实现类似我们伸出了Horizo​​ntalScrollView的东西 - 只覆盖onInterceptTouchEvent和onTouchEvent总是返回false。
然后你只需要把你的菜单中的左侧和右侧的内容(内容必须与屏幕宽度相匹配)。

To achieve something similar we extended a HorizontalScrollView - just overriding onInterceptTouchEvent and onTouchEvent to always return false. Then you just need to put your menu in the left side and the content on the right (the content must match the screen width).

最后设置的初始Horizo​​ntalScrollView滚动并绑定到一个按钮单击事件更改滚动位置(horizo​​ntalScrollView.scrollTo或horizo​​ntalScrollView.smoothScrollTo)。

Finally setup the initial HorizontalScrollView scroll and bind to a button click a event to change the scroll position(horizontalScrollView.scrollTo or horizontalScrollView.smoothScrollTo).

我希望这有助于。

这篇关于避免布局中保证金调整改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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