高仿微信界面

上传者: destiny911911 | 上传时间: 2022-06-02 20:23:29 | 文件大小: 1.03MB | 文件类型: ZIP
下面是安卓开发仿微信界面的代码。 分为3步,第一步是界面的编写,第二步是导航界面,第三步是右上角菜单栏。 开始第一步前先预览一下效果。 第一步,界面。 界面的思路是利用ViewPager+Fragment实现,所以activity_main.xml中添加一个ViewPager。顶部和底部include的顶部栏和底部栏后面再说。 MainActivity的界面activity_main.xml: <?xml version="1.0" encoding="utf-8"?> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 当然,要用到ViewPager+Fragment就要建立Fragment,如图我建了三个Fragment,这个可以根据需要自己创建。 这三个Fragment很类似,这里写出一个,其他以此类推。 package activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.chase.cn.money_of_my.R; /** * Created by Chase on 2017/2/6. */ public class Fragment_tab01 extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View tab01 = inflater.inflate(R.layout.fragment_tab01_home,container,false); return tab01; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 此Fragment对应的xml文件: <?xml version="1.0" encoding="utf-8"?> 1 2 3 4 5 6 7 现在回到MainActivity中: package activity; import ... public class MainActivity extends FragmentActivity { private ViewPager mViewPager; private MyFragmentPagerAdapter mAdapter; private List fragmentList; //保存界面的view @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StatusBarUtil.setWindowStatusBarColor(this, R.color.colorTitleGray); initViews(); initDatas(); } /** * 数据初始化 */ private void initDatas() { //fragment数据源 fragmentList = new ArrayList(); fragmentList.add(new Fragment_tab01()); fragmentList.add(new Fragment_tab02()); fragmentList.add(new Fragment_tab03()); mAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragmentList); mViewPager.setAdapter(mAdapter); } /** * 初始化控件 */ private void initViews() { mViewPager = (ViewPager) findViewById(R.id.vp_mainvp); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 需要编写一个ViewPager的Adapter: package utils; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import java.util.List; /** * Created by Chase on 2017/2/6. */ public class MyFragmentPagerAdapter extends FragmentPagerAdapter { private List fragList; private List tabList; public MyFragmentPagerAdapter(FragmentManager fm, List fragList) { super(fm); this.fragList = fragList; } @Override public CharSequence getPageTitle(int position) { return tabList.get(position); } @Override public Fragment getItem(int position) { return fragList.get(position); } @Override public int getCount() { return fragList.size(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 现在三个Fragment已经添加到了MainActivity中,滑动ViewPager切换Fragment,同时底部的导航栏也会切换,在为ViewPager添加监听以前,先说说底部导航栏。 第二步,底部导航。 这个的切换其实就是切换准备好的png图片和改变文字的颜色。 下面是刚才导入的底部导航栏xml文件: <?xml version="1.0" encoding="utf-8"?> <FrameLayout android:id="@+id/fl_page_home" android:layout_width="wrap_content" android:layout_height="57dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical">

文件下载

资源详情

[{"title":"( 93 个子文件 1.03MB ) 高仿微信界面","children":[{"title":"Top_Button","children":[{"title":"bin","children":[{"title":"res","children":null,"spread":false},{"title":"classes","children":[{"title":"com","children":[{"title":"example","children":[{"title":"top_button","children":[{"title":"HomeFragment$1.class <span style='color:#111;'> 1.20KB </span>","children":null,"spread":false},{"title":"MainActivity.class <span style='color:#111;'> 4.59KB </span>","children":null,"spread":false},{"title":"BuildConfig.class <span style='color:#111;'> 353B </span>","children":null,"spread":false},{"title":"ScanActivity$LeDeviceListAdapter.class <span style='color:#111;'> 3.19KB </span>","children":null,"spread":false},{"title":"R$layout.class <span style='color:#111;'> 808B </span>","children":null,"spread":false},{"title":"R$id.class <span style='color:#111;'> 1.92KB </span>","children":null,"spread":false},{"title":"R$drawable.class <span style='color:#111;'> 830B </span>","children":null,"spread":false},{"title":"ContentAdapter.class <span style='color:#111;'> 1.47KB </span>","children":null,"spread":false},{"title":"HomeFragment$4.class <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false},{"title":"SettingFragment.class <span style='color:#111;'> 1.50KB </span>","children":null,"spread":false},{"title":"FriendFragment$1.class <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"R$dimen.class <span style='color:#111;'> 473B </span>","children":null,"spread":false},{"title":"ArrayAdapterView.class <span style='color:#111;'> 1.24KB </span>","children":null,"spread":false},{"title":"AddressFragment$1.class <span style='color:#111;'> 1.11KB </span>","children":null,"spread":false},{"title":"FriendFragment$2.class <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"ScanActivity$ViewHolder.class <span style='color:#111;'> 487B </span>","children":null,"spread":false},{"title":"R$attr.class <span style='color:#111;'> 352B </span>","children":null,"spread":false},{"title":"FriendFragment$3.class <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"R$menu.class <span style='color:#111;'> 400B </span>","children":null,"spread":false},{"title":"HomeFragment$5.class <span style='color:#111;'> 1.52KB </span>","children":null,"spread":false},{"title":"ScanActivity.class <span style='color:#111;'> 4.64KB </span>","children":null,"spread":false},{"title":"ScanActivity$1$1.class <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false},{"title":"R.class <span style='color:#111;'> 765B </span>","children":null,"spread":false},{"title":"R$array.class <span style='color:#111;'> 413B </span>","children":null,"spread":false},{"title":"SettingFragment$2.class <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"ScanActivity$1.class <span style='color:#111;'> 1.20KB </span>","children":null,"spread":false},{"title":"R$string.class <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"AddressFragment.class <span style='color:#111;'> 1.36KB </span>","children":null,"spread":false},{"title":"HomeFragment$2$1.class <span style='color:#111;'> 1.69KB </span>","children":null,"spread":false},{"title":"HomeFragment$3.class <span style='color:#111;'> 1.03KB </span>","children":null,"spread":false},{"title":"ScanActivity$2.class <span style='color:#111;'> 1.17KB </span>","children":null,"spread":false},{"title":"R$style.class <span style='color:#111;'> 443B </span>","children":null,"spread":false},{"title":"SettingFragment$1.class <span style='color:#111;'> 1.11KB </span>","children":null,"spread":false},{"title":"FriendFragment.class <span style='color:#111;'> 1.63KB </span>","children":null,"spread":false},{"title":"HomeFragment$2.class <span style='color:#111;'> 1.48KB </span>","children":null,"spread":false},{"title":"HomeFragment.class <span style='color:#111;'> 3.04KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"AndroidManifest.xml <span style='color:#111;'> 1.32KB </span>","children":null,"spread":false}],"spread":true},{"title":"res","children":[{"title":"drawable-ldpi","children":null,"spread":false},{"title":"values-v11","children":[{"title":"styles.xml <span style='color:#111;'> 334B </span>","children":null,"spread":false}],"spread":true},{"title":"menu","children":[{"title":"main.xml <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false}],"spread":true},{"title":"values-v14","children":[{"title":"styles.xml <span style='color:#111;'> 391B </span>","children":null,"spread":false}],"spread":true},{"title":"drawable-hdpi","children":[{"title":"item_bg.png <span style='color:#111;'> 2.89KB </span>","children":null,"spread":false},{"title":"tab_settings_normal.png <span style='color:#111;'> 2.31KB </span>","children":null,"spread":false},{"title":"img1.jpg <span style='color:#111;'> 12.90KB </span>","children":null,"spread":false},{"title":"ic_launcher.png <span style='color:#111;'> 7.48KB </span>","children":null,"spread":false},{"title":"tab_find_frd_1.png <span style='color:#111;'> 1.88KB </span>","children":null,"spread":false},{"title":"title_bar.png <span style='color:#111;'> 343B </span>","children":null,"spread":false},{"title":"tab_weixin_1.png <span style='color:#111;'> 1.81KB </span>","children":null,"spread":false},{"title":"tab_settings_1.png <span style='color:#111;'> 3.46KB </span>","children":null,"spread":false},{"title":"tab_address_normal.png <span style='color:#111;'> 272B </span>","children":null,"spread":false},{"title":"tab_address_1.png <span style='color:#111;'> 832B </span>","children":null,"spread":false},{"title":"tab_weixin_pressed.png <span style='color:#111;'> 1003B </span>","children":null,"spread":false},{"title":"tab_find_frd_normal.png <span style='color:#111;'> 1.16KB </span>","children":null,"spread":false}],"spread":false},{"title":"drawable-xhdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 12.22KB </span>","children":null,"spread":false}],"spread":true},{"title":"drawable-xxhdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 24.20KB </span>","children":null,"spread":false}],"spread":true},{"title":"values","children":[{"title":"menu","children":[{"title":"main.xml <span style='color:#111;'> 774B </span>","children":null,"spread":false}],"spread":true},{"title":"strings.xml <span style='color:#111;'> 1.26KB </span>","children":null,"spread":false},{"title":"styles.xml <span style='color:#111;'> 697B </span>","children":null,"spread":false},{"title":"dimens.xml <span style='color:#111;'> 220B </span>","children":null,"spread":false}],"spread":true},{"title":"values-sw720dp-land","children":[{"title":"dimens.xml <span style='color:#111;'> 277B </span>","children":null,"spread":false}],"spread":true},{"title":"drawable-mdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 3.69KB </span>","children":null,"spread":false}],"spread":true},{"title":"values-sw600dp","children":[{"title":"dimens.xml <span style='color:#111;'> 203B </span>","children":null,"spread":false}],"spread":true},{"title":"layout","children":[{"title":"gatt_services_characteristics.xml <span style='color:#111;'> 3.12KB </span>","children":null,"spread":false},{"title":"listview.xml <span style='color:#111;'> 2.64KB </span>","children":null,"spread":false},{"title":"listitem_device.xml <span style='color:#111;'> 1.26KB </span>","children":null,"spread":false},{"title":"page_04.xml <span style='color:#111;'> 3.80KB </span>","children":null,"spread":false},{"title":"activity_main.xml <span style='color:#111;'> 596B </span>","children":null,"spread":false},{"title":"page_03.xml <span style='color:#111;'> 983B </span>","children":null,"spread":false},{"title":"bar_progress.xml <span style='color:#111;'> 400B </span>","children":null,"spread":false},{"title":"activity_top.xml <span style='color:#111;'> 504B </span>","children":null,"spread":false},{"title":"array_item.xml <span style='color:#111;'> 400B </span>","children":null,"spread":false},{"title":"page_01.xml <span style='color:#111;'> 3.80KB </span>","children":null,"spread":false},{"title":"activity_bottom.xml <span style='color:#111;'> 3.43KB </span>","children":null,"spread":false},{"title":"page_02.xml <span style='color:#111;'> 3.24KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"proguard-project.txt <span style='color:#111;'> 781B </span>","children":null,"spread":false},{"title":"ic_launcher-web.png <span style='color:#111;'> 50.19KB </span>","children":null,"spread":false},{"title":"assets","children":null,"spread":false},{"title":"gen","children":[{"title":"com","children":[{"title":"example","children":[{"title":"top_button","children":[{"title":"BuildConfig.java <span style='color:#111;'> 164B </span>","children":null,"spread":false},{"title":"R.java <span style='color:#111;'> 7.29KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":".settings","children":[{"title":"org.eclipse.jdt.core.prefs <span style='color:#111;'> 177B </span>","children":null,"spread":false}],"spread":true},{"title":"src","children":[{"title":"com","children":[{"title":"example","children":[{"title":"top_button","children":[{"title":"SettingFragment.java <span style='color:#111;'> 1.50KB </span>","children":null,"spread":false},{"title":"ScanActivity.java <span style='color:#111;'> 6.16KB </span>","children":null,"spread":false},{"title":"FriendFragment.java <span style='color:#111;'> 1.90KB </span>","children":null,"spread":false},{"title":"AddressFragment.java <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"MainActivity.java <span style='color:#111;'> 7.80KB </span>","children":null,"spread":false},{"title":"ContentAdapter.java <span style='color:#111;'> 988B </span>","children":null,"spread":false},{"title":"ArrayAdapterView.java <span style='color:#111;'> 1.91KB </span>","children":null,"spread":false},{"title":"HomeFragment.java <span style='color:#111;'> 4.82KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":".project <span style='color:#111;'> 846B </span>","children":null,"spread":false},{"title":".classpath <span style='color:#111;'> 475B </span>","children":null,"spread":false},{"title":"project.properties <span style='color:#111;'> 563B </span>","children":null,"spread":false},{"title":"AndroidManifest.xml <span style='color:#111;'> 1.32KB </span>","children":null,"spread":false},{"title":"libs","children":[{"title":"android-support-v4.jar <span style='color:#111;'> 606.89KB </span>","children":null,"spread":false},{"title":"gson-2.2.4.jar <span style='color:#111;'> 185.96KB </span>","children":null,"spread":false},{"title":"LGSCCBABank.jar <span style='color:#111;'> 180.57KB </span>","children":null,"spread":false}],"spread":true}],"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明