1.设置全局样式可以在App.vue里面
2.在每个页面的根view 里添加一个class名叫page
1.设置全局样式可以在App.vue里面
2.在每个页面的根view 里添加一个class名叫page
转载于:https://www.cnblogs.com/wordblog/p/10606003.html
特点:
1、TabLayout使用setCustomView 实现带图标的tab;
2、每个Tab设置不同的背景;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_f4f1f4">
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:layout_below="@id/cl_check_statistic"
app:tabRippleColor="@color/bg_transparent"
app:tabIndicatorHeight="0dp" />
<View
android:id="@+id/divider_line"
android:layout_width="match_parent"
android:layout_height="0.33dp"
android:layout_below="@id/tablayout"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@color/cl_ccc" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/divider_line"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/tabicon"
android:layout_width="15dp"
android:layout_height="15dp" />
<TextView
android:id="@+id/tabtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:textColor="@color/cl_666"
android:textSize="14sp"
tools:text="@string/preview_text" />
</LinearLayout>
@ContentView(R.layout.activity_main)
@ViewModel(MainViewModel.class)
public class MainActivity extends BaseActivity<ActivityMainBinding, MainViewModel>{
private List<Fragment> myFragment;
private String[] titleArr = {"待完成", "待提交", "主动检查"};
private int[] selectedArr = {R.mipmap.icon_pending_selected, R.mipmap.icon_uncommit_selected, R.mipmap.icon_initiative_check_selected};
private int[] unSelectedArr = {R.mipmap.icon_pending_unselected, R.mipmap.icon_uncommit_unselected, R.mipmap.icon_initiative_check_unselected};
private final int DEFAULT_POSITION = 0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initLayout();
}
/**
* 导航栏布局:https://blog.csdn.net/xiaoshuxgh/article/details/80389570
*/
private void initLayout() {
myFragment = new ArrayList<>();
myFragment.add(new PendingFragment());
myFragment.add(new UnCommitFragment());
myFragment.add(new InitiativeCheckFragment());
mBinding.viewpager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
return myFragment.get(i);
}
@Override
public int getCount() {
return myFragment.size();
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
return titleArr[position];
}
});
mBinding.tablayout.setupWithViewPager(mBinding.viewpager);
// 注意:这个方法需要放在setupWithViewPager()后面
for (int i = 0; i < mBinding.tablayout.getTabCount(); i++) {
TabLayout.Tab tabView = mBinding.tablayout.getTabAt(i);
tabView.setCustomView(getTabView(i));
setTabBackground(tabView, false);
}
mBinding.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
//设置选中图标样式
View tabView = tab.getCustomView();
tabView.findViewById(R.id.tabicon).setBackgroundResource(selectedArr[tab.getPosition()]);
//设置选中字体颜色
TextView textView = tabView.findViewById(R.id.tabtext);
textView.setTextColor(getResources().getColor(R.color.theme_color));
setTabBackground(tab, true);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
//设置未选中图标样式
View tabView = tab.getCustomView();
tabView.findViewById(R.id.tabicon).setBackgroundResource(unSelectedArr[tab.getPosition()]);
//设置未选中字体颜色
TextView textView = tabView.findViewById(R.id.tabtext);
textView.setTextColor(getResources().getColor(R.color.cl_666));
setTabBackground(tab, false);
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
setTabBackground(mBinding.tablayout.getTabAt(DEFAULT_POSITION), true);
}
/**
* 使用自定义的View布局
*
* @param position
* @return
*/
private View getTabView(int position) {
View v = LayoutInflater.from(mActivity).inflate(R.layout.icon_view, null);
ImageView iv = v.findViewById(R.id.tabicon);
TextView tv = v.findViewById(R.id.tabtext);
tv.setText(titleArr[position]);
//设置默认页面
if (position == DEFAULT_POSITION) {
iv.setBackgroundResource(selectedArr[position]);
tv.setTextColor(v.getResources().getColor(R.color.theme_color));
} else {
iv.setBackgroundResource(unSelectedArr[position]);
tv.setTextColor(v.getResources().getColor(R.color.cl_666));
}
return v;
}
/**
* TabLayout每个Tab选中背景不一样。
* https://blog.csdn.net/qq_32606467/article/details/103068611
*
* @param tab
* @param selected
*/
private void setTabBackground(TabLayout.Tab tab, boolean selected) {
Drawable drawable = null;
switch (tab.getPosition()) {
case 0:
if (selected) {
drawable = mActivity.getDrawable(R.drawable.tab_background_selected_0);
} else {
drawable = mActivity.getDrawable(R.drawable.tab_background_unselected_0);
}
break;
case 1:
if (selected) {
drawable = mActivity.getDrawable(R.drawable.tab_background_selected_1);
} else {
drawable = mActivity.getDrawable(R.drawable.tab_background_unselected_1);
}
break;
case 2:
if (selected) {
drawable = mActivity.getDrawable(R.drawable.tab_background_selected_2);
} else {
drawable = mActivity.getDrawable(R.drawable.tab_background_unselected_2);
}
break;
}
ViewCompat.setBackground(tab.view, drawable);
}
}
使用金山WPS文本编辑文档时,如果页面空白,则非常单调。如何使WPS文字更单调?实际上,这很简单。仅将图片设置为WPS文本的页面背景是不够的。通常很难找到菜单项命令来在WPS文本中添加背景。但是很快我将非常失望,因为WPS文本不会直接添加可用的后台菜单项命令。以下是在WPS文本中为文档添加背景的几种方法。担心此事的朋友可以借此机会学习,希望本教程对大家有所帮助。
具体步骤:
1。打开WPS文本,选择“插入图片”,然后将图片插入WPS文本。
2。插入图片后,双击图片以进入图片设置属性。选择大小标签,然后选择高度为244.49.,宽度为146.17mm。
3。选择板样式选项卡,然后选择要在文本下方对齐的板样式。点击确定。
4。此时单击图片的颜色进行腐蚀。
5。设置完成后,我们可以在文档中输入文本。如图所示,此时的效果。
其他方法
方法1:在文档的每一页中添加背景
单击菜单栏上的“查看→页眉和页脚”,光标将位于页眉编辑区域中。在“绘图”工具栏中选择“矩形”工具,然后在标题编辑区域中绘制一个矩形。用鼠标拖动矩形的边框以更改刚绘制的矩形的大小以覆盖整个页面。之后,右键单击矩形,然后在弹出的右键菜单中选择“设置对象格式”菜单项命令。
在弹出的“设置对象格式”对话框中,单击“填充颜色”下拉框,您可以在其中选择设置矩形的填充颜色或填充效果。如果只需要向文档中添加背景色,则无需执行此步骤。此步骤介绍添加其他类型的背景,例如图片,纹理等。
在颜色下拉列表中选择“填充效果”命令。在弹出的“填充效果”对话框中,可以设置矩形填充效果颜色渐变,纹理,图案和图片。例如,以添加纹理为例,请在“纹理”中选择“纸张纹理2”的纹理,然后单击“确定”按钮。单击所有弹出对话框上的“确定”按钮,然后关闭“页眉和页脚”编辑区域并返回到文档编辑区域。完成上述步骤后,背景将添加到文档中,并且每页上都有背景,这不会影响您对文档内容的编辑。
方法2:将图片背景添加到文档中
单击菜单栏上的“查看→页眉和页脚”,光标将位于页眉编辑区域中。单击菜单栏上的“插入→图片”以插入您想要作为背景的剪贴画,图片或艺术字。例如:以插入剪贴画为例,选择添加剪贴画。选择您刚刚插入的剪贴画,单击“图片”工具栏上的“文字环绕”按钮,然后选择“文字下方”命令。使用鼠标将添加的剪贴画拖动到合适的位置,关闭“页眉和页脚”编辑区域,然后返回到文档编辑区域。完成上述步骤后,您可以轻松地将图片背景添加到文档中。
通过对以上两种方法的研究,我相信以后您需要在WPS文本中为文档添加背景时不会感到失望。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shumachanpin/article-340879-1.html