首页 文章 精选 留言 我的

精选列表

搜索[UI设计],共10000篇文章
优秀的个人博客,低调大师

2-VVI-材料设计之TabLayout下标签

[1].将下面线去掉,自定义条目样式,就可以实现下图效果 [2].以前实现这种效果一般用按钮组,有点麻烦 [3].Fragment同上篇 效果图 二、代码实现: 1.Activity的布局:a01_bottom.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v4.view.ViewPager android:id="@+id/vp_content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </android.support.v4.view.ViewPager> <android.support.design.widget.TabLayout android:id="@+id/tl_tab" android:layout_width="match_parent" android:layout_height="@dimen/dp_72" android:background="@color/white"> </android.support.design.widget.TabLayout> </LinearLayout> 2.条目的布局:item_01_bottom.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/selector_menu_home"/> <TextView android:id="@+id/tv_menu_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Item" android:textColor="@color/selector_blue"/> </LinearLayout> 3.Activity public class V01_BottomActivity extends AppCompatActivity { private TabLayout mTabTl; private ViewPager mContentVp; private List<String> tabIndicators; private List<Fragment> tabFragments; private FragmentPagerAdapter contentAdapter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.a01_bottom); mTabTl = findViewById(R.id.tl_tab); mContentVp = findViewById(R.id.vp_content); initContent(); initTab(); } private void initTab() { mTabTl.setTabMode(TabLayout.MODE_FIXED); //去除下面线 mTabTl.setSelectedTabIndicatorHeight(0); ViewCompat.setElevation(mTabTl, 10); mTabTl.setupWithViewPager(mContentVp); for (int i = 0; i < tabIndicators.size(); i++) { //获取Tab对应条目 TabLayout.Tab itemTab = mTabTl.getTabAt(i); if (itemTab != null) { //自定义布局加到对应条目上 itemTab.setCustomView(R.layout.item_tab_layout_custom); TextView itemTv = itemTab.getCustomView().findViewById(R.id.tv_menu_item); itemTv.setText(tabIndicators.get(i)); } } } private void initContent() { tabIndicators = DataUtils.getRandomName(5, true); tabFragments = new ArrayList<>(); for (String s : tabIndicators) { tabFragments.add(V01_ContentV4Fragment.newInstance(s)); } //创建适配器对象 contentAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { return tabFragments.get(position); } @Override public int getCount() { return tabIndicators.size(); } @Override public CharSequence getPageTitle(int position) { return tabIndicators.get(position); } }; mContentVp.setAdapter(contentAdapter); } } 后记、 1.声明: [1]本文由张风捷特烈原创,转载请注明 [2]欢迎广大编程爱好者共同交流 [3]个人能力有限,如有不正之处欢迎大家批评指证,必定虚心改正 [4]你的喜欢与支持将是我最大的动力 2.连接传送门: 更多安卓技术欢迎访问:安卓技术栈 我的github地址:欢迎star 简书首发,腾讯云+社区同步更新张风捷特烈个人网站,编程笔记请访问:http://www.toly1994.com 3.联系我 QQ:1981462002 邮箱:1981462002@qq.com 微信:zdl1994328 4.欢迎关注我的微信公众号,最新精彩文章,及时送达: 公众号.jpg

优秀的个人博客,低调大师

读书笔记-JavaScript高级程序设计(1)

1.组合继承 (JavaScript中最常用的继承模式 ) (position: page168) (书中定义了两个变量名SuperType SubType 乍一看 感觉不太能区分,我将改为 a b ,更加明显区分开来这是两个东西。) function a(name){ this.name = name; this.colors = ["red", "blue", "green"]; } a.prototype.sayName = function(){ alert(this.name);} function b(name, age){ //继承属性 a.call(this, name); this.age = age; } //继承方法 b.prototype = new a(); b.prototype.constructor = b; b.prototype.sayAge = function(){ alert(this.age); }; var instance1 = new b("Nicholas", 29); instance1.colors.push("black"); alert(instance1.colors); //"red,blue,green,black" instance1.sayName(); //"Nicholas"; instance1.sayAge(); //29 var instance2 = new b("Greg", 27); alert(instance2.colors); //"red,blue,green" instance2.sayName(); //"Greg"; instance2.sayAge(); //27 完成继承的思路: 使用原型链实现对原型属性和方法的继承, 使用构造函数来实现对实例属性的继承。 在这个例子中, a构造函数定义了两个属性: name 和 colors。 a的原型定义了一个方法 sayName()。 b构造函数在调用 a构造函数时传入了 name 参数,紧接着又定义了它自己的属性 age。然后,将 a的实例赋值给 b的原型, 然后又在该新原型上定义了方法 sayAge()。这样一来,就可以让两个不同的 b 实例既分别拥有自己属性——包括 colors 属性,又可以使用相同的方法了。 2.寄生组合式继承 (实现基于类型继承的最有效方式 ) function object(o){ function F(){} F.prototype = o; return new F(); } function inheritPrototype(subType, superType){ var prototype = object(superType.prototype); //创建对象 prototype.constructor = subType; //增强对象 subType.prototype = prototype; //指定对象 } function a(name){ this.name = name; this.colors = ["red", "blue", "green"]; } a.prototype.sayName = function(){ alert(this.name); }; function b(name, age){ a.call(this, name); this.age = age; } inheritPrototype(b, a); b.prototype.sayAge = function(){ alert(this.age); }; // 调用 var instance1 = new b("Nicholas", 29); instance1.colors.push("black"); alert(instance1.colors); //"red,blue,green,black" instance1.sayName(); //"Nicholas"; instance1.sayAge(); //29 var instance2 = new b("Greg", 27); alert(instance2.colors); //"red,blue,green" instance2.sayName(); //"Greg"; instance2.sayAge(); //27

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码