在我的标签布局中,我有3个标签。这个标签的标题默认都是大写字母,我想将Bole,Italic和字体大小等样式应用于标签。 我正在使用选项卡布局并将NoActionBar作为样式查看寻呼机。是否可以为标签标题应用样式
回答
这是不可能的样式应用到默认选项卡title.Following链接将帮助您创建自定义选项卡。
http://mrbool.com/how-to-customize-tab-layout-in-android/28153
该链接对于创建自定义选项卡非常有用。 –
是的,你可以,只要按照这个
custom_tab_item
:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tab"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/tab_label"/>
main_layout
:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="bold"
style="@android:style/TextAppearance.Medium"
android:text="Toolbar Title" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white"
app:tabMode="fixed" />
Activity
:
public class DiningActivity extends AppCompatActivity {
private Toolbar mToolbar;
private TabLayout mTabLayout;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dining);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
((TextView) findViewById(R.id.toolbar_title)).setText(R.string.dining);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mViewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(mViewPager);
mTabLayout = (TabLayout) findViewById(R.id.tabs);
mTabLayout.setupWithViewPager(mViewPager);
setupTabs();
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new RestaurantFragment(), getString(R.string.restaurants));
adapter.addFragment(new HotelsFragment(), getString(R.string.hotels));
adapter.addFragment(new BarsPubsFragment(), getString(R.string.bars_pubs));
viewPager.setAdapter(adapter);
}
private void setupTabs() {
TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab_item, null);
tabOne.setText(getString(R.string.restaurants));
mTabLayout.getTabAt(0).setCustomView(tabOne);
TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab_item, null);
tabTwo.setText(getString(R.string.hotels));
mTabLayout.getTabAt(1).setCustomView(tabTwo);
TextView tabThree = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab_item, null);
tabThree.setText(getString(R.string.bars_pubs));
mTabLayout.getTabAt(Numerics.TWO).setCustomView(tabThree);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
super.onBackPressed();
}
return super.onOptionsItemSelected(item);
}
}
如果我们想要应用任何尺寸和风格,我们可以在custom_tab_item.layout中提到。我明白这是正确还是错误? –
是的,你是对的 –
k我会试试这个,让你知道它是工作r不是。 –
内android.support.design.widget.TabLayout设置主题属性这样
android:theme="@style/Base.Widget.Design.TabLayout"
,风格定义主题
<style name="Base.Widget.Design.TabLayout" parent="android:Widget">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
</style>
它不是工作风格是应用于标签中的文本而不是标签标题。我想将样式应用于**标题标题**。 –
- 1. 在PyCharm中,是否可以禁用隐藏样式标签?
- 2. Css标题标签样式
- 3. 是否可以创建一个标签样式字段?
- 4. 是否可以设置单个标签栏的样式?
- 5. abbr标签的标题可以被样式化吗?
- 6. 用css重置样式标题标签
- 7. 我们可以在标题中设置样式到标题标签
- 8. 是否可以在运行时更改UIBarButtonItem标题和样式?
- 9. 是否可以编辑UIAlertAction标题字体大小和样式?
- 10. 是否可以为scatter.smooth添加标题?
- 11. 是否可以使用PhoneGap读取nfc标签UID?怎么样?
- 12. 是否可以/允许使用具有标签标签的ID
- 13. 对span标签的标题应用样式
- 14. CSS - 样式图像标签的标题
- 15. 反应标签不作为标签样式
- 16. JQuery:是否可以设置<a>标签样式以改变点击?
- 17. 是否可以将标签放入actionColumn?
- 18. 是否可以检索黄瓜标签?
- 19. 是否可以在ASP标签之间添加HTML标签?
- 20. 是否可以在选项中添加标签标签?
- 21. 是否可以将id添加到标签标签?
- 22. 是否可以使用正则表达式与cucumber.options标签?
- 23. 是否可以在AutoCad中以编程方式创建标签?
- 24. 是否可以锚定表视图标题(不是节标题)
- 25. 是否可以使用display:table标签创建嵌套标头?
- 26. 是否可以为响应式设计缩放导航图标?
- 27. 是否可以使用Jsp include标签作为iframe源?
- 28. 为什么html标签可以被样式化和看到?
- 29. 是否可以根据它的输入类型来设置标签的样式?
- 30. GridView是否可以像ListView一样具有页脚和标题?
是..its可能 – shahid17june
你可以发布,我们可以将这些风格answer.How? –
当然..只是给我几分钟.. – shahid17june