谷歌的Andr​​oid滑动标签布局 [英] Google's Android Sliding Tabs Layout

查看:219
本文介绍了谷歌的Andr​​oid滑动标签布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地使用谷歌的滑动标签code在我的项目。 (示例项目可以在这里找到: http://developer.android.com/samples/SlidingTabsBasic /index.html )这是我到目前为止有:

I have successfully used Google's Sliding Tabs code in my project. (Sample project can be found here: http://developer.android.com/samples/SlidingTabsBasic/index.html) This is what I have so far:

不幸的是,我无法弄清楚如何使标签占据整个酒吧。如下所示,它们占用了仅约一半的屏幕。我认为改变填充,但我不希望到c很难$ C $,因为不同的屏幕尺寸。我的最终目标是模拟的标签布局YouTube使用:

Unfortunately, I am unable to figure out how to make the tabs take up the entire bar. As shown below, they are taking up only approximately half the screen. I considered changing the padding, but I don't want to hard code it because of varying screen sizes. My ultimate goal is to emulate the tab layout that YouTube uses:

推荐答案

您可能会发现在 setDistributeEvenly 如果您使用来自

You probably find the setDistributeEvenly method cannot be resolved if you use the sample code from

<一个href="http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html" rel="nofollow">http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html

然后在 createDefaultTabView 您的 SlidingTabLayout 类的方法,在返回的TextView前添加以下行

Then in the createDefaultTabView method of your SlidingTabLayout class, add the following line before returning the textView

textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f));

这篇关于谷歌的Andr​​oid滑动标签布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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