20189208 2018-2019-2 《移动平台开发实践》分析小组项目代码
发布时间:2020-12-16 23:15:38 所属栏目:百科 来源:网络整理
导读:20189208 2018-2019-2 《移动平台开发实践》分析小组项目代码 对我所负责的代码部分进行分析 activity_main.xml RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:to
20189208 2018-2019-2 《移动平台开发实践》分析小组项目代码对我所负责的代码部分进行分析 activity_main.xml<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="50dp" android:layout_margin="0dp"> <TextView android:id="@+id/main_myMusic" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="本地音乐" android:textSize="20sp" /> <TextView android:id="@+id/main_myRecord" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="我的歌单" android:textSize="20sp" /> </LinearLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="wrap_content" tools:context=".MainActivity" /> </RelativeLayout> activity_play.xml<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> //设置背景图片 <ImageView android:id="@+id/listen_background_iv" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" /> //设置唱片圆盘 <ImageView android:id="@+id/imageView1_ablum" android:layout_width="250dp" android:layout_height="250dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@mipmap/default_cover" /> //设置圆盘上的指针 <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="0dp" android:layout_marginTop="0dp" android:layout_marginBottom="15dp"> <RelativeLayout android:id="@+id/listen_play" android:layout_width="match_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_marginBottom="0dp"> //设置收藏 <ImageView android:id="@+id/play_activity_myLove" android:layout_width="40dp" android:layout_height="40dp" android:layout_centerVertical="true" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:src="@mipmap/heart_fill" /> //设置“上一首” <ImageView android:id="@+id/imageView3_previous" android:layout_width="40dp" android:layout_height="40dp" android:layout_centerVertical="true" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:layout_toLeftOf="@id/imageView2_play_pause" android:src="@mipmap/back_w" /> //设置“暂停” <ImageView android:id="@+id/imageView2_play_pause" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@mipmap/play_circle" /> //设置下一首 <ImageView android:id="@+id/imageView1_next" android:layout_width="40dp" android:layout_height="40dp" android:layout_centerVertical="true" android:layout_marginLeft="30dp" android:layout_toRightOf="@id/imageView2_play_pause" android:src="@mipmap/next_w" /> //设置播放模式 <ImageView android:id="@+id/imageView1_play_mode" android:layout_width="40dp" android:layout_height="40dp" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" android:layout_marginTop="10dp" android:layout_toEndOf="@+id/imageView1_next" android:src="@mipmap/single_play" /> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@id/listen_play" android:layout_marginBottom="10dp" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingRight="10dp"> //设置“当前歌曲时间” <TextView android:id="@+id/textView1_start_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="00:00" /> //设置“进度条” <SeekBar android:id="@+id/seekBar1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> //设置“歌曲总时长” <TextView android:id="@+id/textView1_end_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="02:30" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="90dp" android:gravity="center_horizontal" android:orientation="vertical"> //android:background="@color/colorAccent" <TextView android:id="@+id/msc_title" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" android:clickable="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:hapticFeedbackEnabled="true" android:marqueeRepeatLimit="marquee_forever" android:maxWidth="250dp" android:singleLine="true" android:text="为了测试单行文字滚动而取的长歌名" android:textColor="#333333" android:textSize="30dp" /> <TextView android:id="@+id/msc_artist" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="石进" android:textColor="#333333" android:textSize="20dp" /> </LinearLayout> </RelativeLayout> </RelativeLayout> activity_splash.xml<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".SplashActivity"> <Button android:id="@+id/skip" android:layout_width="84dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="16dp" android:text="跳过" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.915" app:layout_constraintStart_toStartOf="parent" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="200dp" android:layout_marginEnd="8dp" android:text="@string/lxq" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:text="@string/zhy" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView2" app:layout_constraintVertical_bias="0.05" /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:text="@string/ycx" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView3" app:layout_constraintVertical_bias="0.05" /> <Button android:id="@+id/btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:layout_marginEnd="8dp" android:text="显示学号" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.479" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView4" /> </android.support.constraint.ConstraintLayout> fragment_bottom_info.xml<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/background_light" tools:context=".bottomInfoFr"> <LinearLayout android:id="@+id/bottom_info_duration" android:layout_width="match_parent" android:layout_height="46dp" android:orientation="horizontal" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/bottom_info_title"> <TextView android:id="@+id/left_durationi" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:paddingLeft="10dp" android:text="播放时长" /> <TextView android:id="@+id/right_duration" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center_vertical" android:text="TextView" /> </LinearLayout> <LinearLayout android:id="@+id/bottom_info_title" android:layout_width="match_parent" android:layout_height="46dp" android:orientation="horizontal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0"> <TextView android:id="@+id/left_title" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:paddingLeft="10dp" android:text="文件名称" /> <TextView android:id="@+id/right_title" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center_vertical" android:text="TextView" /> </LinearLayout> <LinearLayout android:id="@+id/bottom_info_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingBottom="10dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/bottom_info_size"> <TextView android:id="@+id/left_url" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:paddingLeft="10dp" android:text="文件路径" /> <TextView android:id="@+id/right_url" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center_vertical" /> </LinearLayout> <LinearLayout android:id="@+id/bottom_info_size" android:layout_width="match_parent" android:layout_height="46dp" android:orientation="horizontal" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/bottom_info_artist"> <TextView android:id="@+id/left_size" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:paddingLeft="10dp" android:text="文件大小" /> <TextView android:id="@+id/right_size" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center_vertical" /> </LinearLayout> <LinearLayout android:id="@+id/bottom_info_artist" android:layout_width="match_parent" android:layout_height="46dp" android:orientation="horizontal" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/bottom_info_duration"> <TextView android:id="@+id/left_artist" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:paddingLeft="10dp" android:text="歌手名称" /> <TextView android:id="@+id/right_artist" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center_vertical" /> </LinearLayout> </android.support.constraint.ConstraintLayout> fragment_my_music_list.xml<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MyMusicListFragment" app:layout_editor_absoluteY="81dp"> <ListView android:id="@+id/listView_my_music" android:layout_width="wrap_content" android:layout_height="420dp" android:layout_marginLeft="8dp" android:layout_marginEnd="8dp" android:visibility="visible" app:layout_constraintBottom_toTopOf="@+id/listen_rl" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <RelativeLayout android:id="@+id/listen_rl" android:layout_width="match_parent" android:layout_height="70dp" app:layout_constraintBottom_toBottomOf="parent" tools:layout_editor_absoluteX="0dp"> //设置布局间的分割线 <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="#bababa" /> //设置封面 <ImageView android:id="@+id/listen_cover_iv" android:layout_width="60dp" android:layout_height="60dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:src="@mipmap/back1" /> //设置歌曲名 <TextView android:id="@+id/listen_title_tv" android:layout_width="wrap_content" android:maxWidth="140dp" android:ellipsize="end" android:singleLine="true" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginTop="8dp" android:layout_toRightOf="@id/listen_cover_iv" android:text="xxx" android:textColor="#aeabab" android:textSize="20sp" /> //设置歌手名 <TextView android:id="@+id/listen_artist_tv" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_below="@id/listen_title_tv" android:layout_alignLeft="@id/listen_title_tv" android:layout_gravity="center" android:layout_marginTop="5dp" android:clickable="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:textColor="#aeabab" android:textSize="15sp" /> //设置专辑名 <TextView android:id="@+id/listen_album_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@id/listen_artist_tv" android:layout_toRightOf="@id/listen_artist_tv" android:textColor="#aeabab" android:textSize="15sp" /> //设置播放暂停 <ImageView android:id="@+id/playmusic" android:layout_width="30dp" android:layout_height="30dp" android:layout_toRightOf="@id/listen_album_tv" android:layout_marginLeft="50dp" android:layout_centerVertical="true" android:src="@mipmap/play_circle" /> <!--android:layout_alignParentRight="true"--> <!--android:layout_marginRight="63dp"--> //设置收藏 <ImageView android:id="@+id/mylove" android:layout_width="30dp" android:layout_height="30dp" android:layout_toRightOf="@id/playmusic" android:layout_centerVertical="true" android:src="@mipmap/heart_fill" /> <!--android:layout_alignParentRight="true"--> <!--android:layout_marginRight="15dp"--> </RelativeLayout> </android.support.constraint.ConstraintLayout> item_music_list.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"> //运用相对布局文件 <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp" android:orientation="vertical" android:gravity="center" android:layout_gravity="center" > //创建列表歌曲间的横线 <View android:id="@+id/list_column_v" android:layout_width="0.5dp" android:layout_height="match_parent" android:visibility="visible" ></View> //设置专辑图片样式 <ImageView android:id="@+id/simple_cover_Iv" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignBottom="@+id/linearLayout" android:layout_marginLeft="11dp" android:layout_toRightOf="@+id/list_column_v" android:src="@mipmap/default_cover" /> //运行线性布局文件进行TextView布局 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/simple_cover_Iv" android:orientation="vertical" android:layout_marginTop="5dp" android:layout_marginLeft="5dp" android:id="@+id/linearLayout"> //创建歌曲名布局代码 <TextView android:id="@+id/textView1_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Something just like this" /> //创建歌曲专辑及作者名代码 <TextView android:id="@+id/textView2_singer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:text="Cold Player/The Chainsmokers" /> </LinearLayout> //创建“更多选项”图片 <ImageView android:id="@+id/simple_more_iv" android:layout_width="50dp" android:layout_height="20dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@mipmap/ic_music_list_icon_more" /> </RelativeLayout> </LinearLayout> local.xml<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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" xmlns:tools="http://schemas.android.com/tools"> <LinearLayout android:id="@+id/linearLayout4" android:layout_width="match_parent" android:layout_height="555dp" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" > <ListView android:id="@+id/sp_listview" android:layout_width="match_parent" android:layout_height="wrap_content" tools:context=".MainActivity" /> </LinearLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" /> </android.support.constraint.ConstraintLayout> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |