如何在android中使用框架布局
我必须创建一个 android 布局,顶部有一个 textview
,在该 textview
下有一个 imageview
和一个 imagebutton
> 在 imageview
下。
当触摸 imagebutton
时,textview
和 imageview
必须变得不可见,并且自定义视图必须在 textview< 的位置变得可见。 /code> 和
imageview
是。
如果我使用线性布局,我必须使用 margintop 白色负值,但我认为这不是很有用,因为在不同的屏幕尺寸上它会显示得非常糟糕。我想我必须使用 framelayout
但我不知道该怎么做,谁能解释一下它是如何工作的吗?
非常感谢你!
i have to create an android layout which has a textview
on the top, an imageview
under that textview
and a imagebutton
under imageview
.
When imagebutton
is touched, the textview
and imageview
have to become invisible and a custom view must become visibile in the place where textview
and imageview
was.
If i use linearlayout
, i have to use margintop whit negative values, but i think is not very useful cause on different screen size it will shown very bad. I think i have to use framelayout
but i don't know how to do, can anyone explain me well how it work pls?
thanks you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么要采用 FrameLayout?在您的 LinearLayout 中执行此操作。当触摸 imageButton 时,将文本和 imageView 设置为:
并将您的自定义视图设置为 View.Visible。
我猜你的边距是负数,因为你尝试了像 View.Invisible 这样的东西。
您可以参考docs,查看,每个州做什么。
Why you want to take an FrameLayout? do it inside your LinearLayout. When imageButton is touched set text and imageView like this :
and your customView to View.Visible.
I guess you came to negative margins, because you tried something like View.Invisible.
You can refer to the docs, to see, what each state does.
比 LinearLayout 更好的方法是使用relativelayout。为覆盖组件提供相同的属性,并且不要设置相对属性,例如layoutabove 或layoutbelow。
A better way than LinearLayout is using RelativeLayout. Give the same attributes to the overlaying components and do not set the relative attributes like layoutabove or layoutbelow.