如何在 Android 中创建自定义选项卡/视图?
任何人都可以帮我创建高度定制的用户界面,如下所示。
Labels: tab1 | tab2 | tab3
==========v===============
Customized ListView
...
我成功创建了自定义列表视图。我的问题是创建自定义选项卡。
在网上一些教程和示例的帮助下,我使用自定义 TextView 来创建自定义选项卡。我的问题是:
- 如何在所选选项卡/视图正下方显示“向下箭头”并覆盖选项卡下方双线的一部分。
从设计中可以看出,第一个是标签文本,然后是选项卡。因此,选项卡内容仅覆盖选项卡下方的区域,并将标签下方的区域留空。像这样的事情
标签:tab1 |选项卡2 |选项卡3 =========v=============== 自定义列表视图 ...
我怎样才能通过XML设置覆盖屏幕的整个宽度?
我能够解决我的第一个问题如下。我通过以下方式创建了一个自定义选项卡:
LinearLayout(Vertical Oriantation)
---- TextView
---- RelativeLayout
----LinearLayout
---- double Line
----DownArrow ImageView(with android:layout_centerInParent = "true", this made the arrow over write the double line)
最后通过编程根据所选选项卡使 DownArrow ImageView 不可见和可见。
我仍然被第二个问题困扰。
Can anyone please help me creating highly customized UI as shown below.
Labels: tab1 | tab2 | tab3
==========v===============
Customized ListView
...
I managed to create the Customized ListView. My problem is creating the Customized tabs.
With help of few tutorials and examples on net, I used Customized TextView for creating Customized Tabs. My problems are:
- how to show an 'down arrow' exactly below the selected tab/View and overwrite a part of double line below the tabs.
As you can see from the design, the first one is the Lable text and then the tabs. Because of this the tab Content covers only the area below the tabs and leaves area below Labels empty. Something like this
Labels: tab1 | tab2 | tab3 ==========v=============== Customized ListView ...
How can I cover the whole width of the screen through XML settings?
I am able to solve my first problem as follows. I created a custom tab in the following way:
LinearLayout(Vertical Oriantation)
---- TextView
---- RelativeLayout
----LinearLayout
---- double Line
----DownArrow ImageView(with android:layout_centerInParent = "true", this made the arrow over write the double line)
And finally through programming made DownArrow ImageView Invisible and Visible according to the tabs selected.
I am still stuck with the my second Problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决您的问题的最简单的方法是您有一个带有三个
Buttons
(或TextViews
)的LinearLayout
,它将隐藏您的选项卡。然后,您应该向这些按钮添加所需的样式,并实现所有所需的 onclick 功能(即设置未选择的其他两个视图等),但您不必为选项卡设置样式,这会带来时间,这是一种痛苦。希望这有帮助!
The most easy solution to your problem is you have a
LinearLayout
with threeButtons
(orTextViews
) which will hide your tab. Then you should add the required style to these buttons and implement all the required onclick functionality (i.e. set unselected the other two views, etc, etc), but you gain time by not be obliged to style the tabs, which is a pain.Hope this helps!