如何把向上或向下编程一个看法? [英] How to put up or down a view programatically?

查看:198
本文介绍了如何把向上或向下编程一个看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML的基本骨架是

I have a xml that the basic "skeleton" is

<RelativeLayout>
    <FrameLayout>
        <RelativeLayout>
            <TextView>
            </TextView>
            <TextView>
            </TextView>
        </RelativeLayout>
        <DrawView>
            //The view that changes 1
        </DrawVIew>
        <EditText>
            //The view that changes 2
        </EditText>
    </FrameLayout>
    <RelativeLayout>
    </RelativeLayout>
</RelativeLayout>

我要的是,使用code中的DrawView上升或下降,所以有时你可以使用DrawView而在其他时刻,你可以使用的EditText,但有史以来两个视图显示。

What I want is that using code the DrawView goes up or down, so sometimes you can use the DrawView and in other moments you can use the EditText, but ever the two views are showed.

我怎么能这样做?

推荐答案

既然你都放置一个小工具里面的FrameLayout你可以改变它的引力象下面这样:

Since you are placing both widgets inside a FrameLayout you can change its gravity like below:

FrameLayout.LayoutParams drawViewLayoutParams = drawView.getLayoutParams();
drawViewLayoutParams.gravity = Gravity.BOTTOM;

FrameLayout.LayoutParams editTextLayoutParams = editText.getLayoutParams();
editTextLayoutParams.gravity = Gravity.TOP;

这篇关于如何把向上或向下编程一个看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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