首页 > 代码库 > 2017.1.16 进度 项目4开头
2017.1.16 进度 项目4开头
今天的大部分时间都用在想UI怎么设计以及,如何把button放在title bar上,结果后者怎么也实现不了,于是只好先放弃在这次的这个音乐播放半成品里面使用了。
其实想想也是,这次的主要考察对象是activity之间的转换,我总是把它的重点跑偏……
放上代码存个档:
activity_main.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:id="@+id/activity_main" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:orientation="vertical" 8 android:background="@color/whole" 9 tools:context="com.example.android.ourmusic.MainActivity"> 10 11 <TextView 12 android:id="@+id/play_now" 13 style="@style/text" 14 android:layout_width="match_parent" 15 android:background="@color/play_now" 16 android:text="@string/play_now" 17 android:textSize="24sp" /> 18 19 <ScrollView 20 android:layout_width="match_parent" 21 android:layout_height="wrap_content"> 22 23 <TextView 24 android:id = "@+id/local_music" 25 style="@style/text" 26 android:text="@string/local_music" /> 27 </ScrollView> 28 </LinearLayout>
color.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <resources> 3 <color name="colorPrimary">#696969</color> 4 <color name="colorPrimaryDark">#696969</color> 5 <color name="colorAccent">#FF4081</color> 6 <color name="play_now">#DCDCDC</color> 7 <color name="whole">#F5F5F5</color> 8 </resources>
style.xml
1 <resources> 2 3 <!-- Base application theme. --> 4 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 5 <!-- Customize your theme here. --> 6 <item name="colorPrimary">@color/colorPrimary</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 8 <item name="colorAccent">@color/colorAccent</item> 9 </style> 10 11 <!--For most of TextView--> 12 <style name="text"> 13 <item name="android:layout_width">match_parent</item> 14 <item name="android:layout_height">wrap_content</item> 15 <item name="android:textSize">24sp</item> 16 <item name="android:layout_margin">8dp</item> 17 <item name="android:gravity">center_horizontal</item> 18 <item name="android:layout_gravity">center_horizontal</item> 19 <item name="android:textColor">@android:color/black</item> 20 <item name="android:background">@color/play_now</item> 21 <item name="android:padding">16dp</item> 22 23 </style> 24 25 </resources>
string.xml
<resources> <string name="app_name">Our Music</string> <string name="action_play">play</string> <string name="local_music">本地音乐</string> <string name="download_manage">下载管理</string> <string name="rencent_play">最近播放</string> <string name="my_music_list">我的歌单</string> <string name="default_music_list">默认歌单</string> <string name="creat_new_music_list">创建新的歌单</string> <string name="play_now">正在播放</string> </resources>
还有个不会用的menu.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app = "http://schemas.android.com/apk/res-auto"> <!-- "Mark Favorite", should appear as action button if possible --> <item android:id="@+id/action_play" android:icon="@drawable/music" android:title="@string/play" app:showAsAction="ifRoom"/> </menu> </resources>
MainActivity.java
1 package com.example.android.ourmusic; 2 3 import android.graphics.Typeface; 4 import android.os.Bundle; 5 import android.support.v7.app.AppCompatActivity; 6 import android.widget.TextView; 7 8 public class MainActivity extends AppCompatActivity { 9 10 @Override 11 protected void onCreate(Bundle savedInstanceState) { 12 super.onCreate(savedInstanceState); 13 setContentView(R.layout.activity_main); 14 String customFont = "汉仪南宫体简.ttf"; 15 Typeface typeface = Typeface.createFromAsset(getAssets(), customFont); 16 TextView textView = (TextView) findViewById(R.id.play_now); 17 TextView textView1 = (TextView)findViewById(R.id.local_music); 18 textView.setTypeface(typeface); 19 textView1.setTypeface(typeface); 20 } 21 22 }
哎每次一总结就发现自己写的东西特别少……还花了两个多小时?好废哦……
2017.1.16 进度 项目4开头
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。