ViewPager+FrameLayout+sever 音乐播放器
3个FrameLayout 创建就可以了 里面不用写东西 第一个FrameLayout package com.example.myapplication105; import android.os.Bundle; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * A simple {@link Fragment} subclass. */ public class BlankFragment extends Fragment { public BlankFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_blank, container, false); } } 第二个FrameLayout 创建就可以了 里面不用写东西 package com.example.myapplication105; import android.os.Bundle; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * A simple {@link Fragment} subclass. */ public class BlankFragment2 extends Fragment { public BlankFragment2() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_blank_fragment2, container, false); } }第3个
package com.example.myapplication105; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import java.util.Timer; import java.util.TimerTask; /** * A simple {@link Fragment} subclass. */ public class BlankFragment3 extends Fragment { private TextView time; private int index=3; public Handler handler = new Handler() { @Override public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); if (msg.what == 100) { time.setText("倒计时"+index--+"S"); if (index==0){ Intent intent1=new Intent(getContext(),Main2Activity.class); startActivity(intent1); } } if (msg.what == 110) { Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { handler.sendEmptyMessage(100); } }, 0, 1000); } } }; public BlankFragment3() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View inflate = inflater.inflate(R.layout.fragment_blank_fragment3, container, false); time = (TextView) inflate.findViewById(R.id.time); return inflate; } }MainActivity
package com.example.myapplication105; import android.os.Bundle; import android.widget.ImageView; import android.widget.LinearLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; public class MainActivity extends AppCompatActivity { private ViewPager vp; private BlankFragment blankFragment = new BlankFragment(); private BlankFragment2 blankFragment2 = new BlankFragment2(); private BlankFragment3 blankFragment3 = new BlankFragment3(); private MyFragement myFragement; private LinearLayout ll; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); final List<Fragment> list = new ArrayList<>(); list.add(blankFragment); list.add(blankFragment2); list.add(blankFragment3); myFragement = new MyFragement(getSupportFragmentManager(), list); vp.setAdapter(myFragement); final List<ImageView> iglist = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { ImageView ig = new ImageView(this); if (i == 0) { ig.setImageResource(R.drawable.next); } else { ig.setImageResource(R.drawable.up); } iglist.add(ig); ll.addView(ig); } final Timer timer=new Timer(); timer.schedule(new TimerTask() { int p=0; @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { vp.setCurrentItem(p); p++; if (p>list.size()){ timer.cancel(); } } }); } },0,1000); vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { if (position==list.size()-1){ blankFragment3.handler.sendEmptyMessage(110); } for (int i = 0; i <iglist.size() ; i++) { ImageView imageView = iglist.get(i); if (i==position){ imageView.setImageResource(R.drawable.next); }else { imageView.setImageResource(R.drawable.up); } } } @Override public void onPageScrollStateChanged(int state) { } }); } private void initView() { vp = (ViewPager) findViewById(R.id.vp); ll = (LinearLayout) findViewById(R.id.ll); } } Music package com.example.myapplication105; public class Music { private String title; private String artist; private String duartion; private String data; private String size; private String albumId; public Music(String title, String artist, String duartion, String data, String size, String albumId) { this.title = title; this.artist = artist; this.duartion = duartion; this.data = data; this.size = size; this.albumId = albumId; } public Music() { } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getArtist() { return artist; } public void setArtist(String artist) { this.artist = artist; } public String getDuartion() { return duartion; } public void setDuartion(String duartion) { this.duartion = duartion; } public String getData() { return data; } public void setData(String data) { this.data = data; } public String getSize() { return size; } public void setSize(String size) { this.size = size; } public String getAlbumId() { return albumId; } public void setAlbumId(String albumId) { this.albumId = albumId; } @Override public String toString() { return "Music{" + "title='" + title + '\'' + ", artist='" + artist + '\'' + ", duartion='" + duartion + '\'' + ", data='" + data + '\'' + ", size='" + size + '\'' + ", albumId='" + albumId + '\'' + '}'; } } BaseAdapter package com.example.myapplication105; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.List; public class Myapdate extends BaseAdapter { private Context context; private List<Music> list; public Myapdate(Context context, List<Music> list) { this.context = context; this.list = list; } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder=null; if (convertView==null){ viewHolder=new ViewHolder(); convertView= LayoutInflater.from(context).inflate(R.layout.item,null); viewHolder.gm=convertView.findViewById(R.id.gm); viewHolder.gs=convertView.findViewById(R.id.gs); viewHolder.sj=convertView.findViewById(R.id.sj); convertView.setTag(viewHolder); }else { viewHolder= (ViewHolder) convertView.getTag(); } Music music = list.get(position); String title = music.getTitle(); String artist = music.getArtist(); String duartion = music.getDuartion(); viewHolder.gm.setText(title); viewHolder.gs.setText(artist); viewHolder.sj.setText(MyMusucID.fmtTime(duartion)); return convertView; } private class ViewHolder { private ImageView ig; private TextView gm,gs,sj; } } MyFragement连接Fragement的 package com.example.myapplication105; import android.content.Context; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import java.util.List; public class MyFragement extends FragmentStatePagerAdapter { private List<Fragment> list; public MyFragement(@NonNull FragmentManager fm, List<Fragment> list) { super(fm); this.list=list; } @NonNull @Override public Fragment getItem(int position) { return list.get(position); } @Override public int getCount() { return list.size(); } } 获取数据 package com.example.myapplication105; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import java.util.ArrayList; import java.util.List; public class MyMusucID { public static final int ONE=0; public static final int TWO=1; public static final int THREE=2; public static List<Music> getMusic(Context context) { List<Music> list=new ArrayList<>(); Uri uri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; ContentResolver conn=context.getContentResolver(); Cursor query = conn.query(uri, null, null, null, null); if (query!=null){ while (query.moveToNext()){ String string = query.getString(query.getColumnIndex(MediaStore.Audio.Media.TITLE)); String string1 = query.getString(query.getColumnIndex(MediaStore.Audio.Media.ARTIST)); String string2 = query.getString(query.getColumnIndex(MediaStore.Audio.Media.DURATION)); String string3 = query.getString(query.getColumnIndex(MediaStore.Audio.Media.DATA)); String string4 = query.getString(query.getColumnIndex(MediaStore.Audio.Media.SIZE)); String string5 = query.getString(query.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID)); Music music=new Music(string,string1,string2,string3,string4,string5); if (Integer.parseInt(string2)>=6*1000){ list.add(music); } } query.close(); } return list; } public static String fmtTime(String time){ //3:15 3:09 int i = Integer.parseInt(time); if(i /1000 % 60 < 10){ return i/1000/60+":0"+i/1000%60; } return i / 1000 /60 +":"+ i /1000 % 60; } } MyService package com.example.myapplication105; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.media.MediaPlayer; import android.os.Binder; import android.os.IBinder; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.PopupWindow; import android.widget.RemoteViews; import android.widget.TextView; import android.widget.Toast; import java.io.IOException; import java.io.PipedOutputStream; import java.util.ArrayList; import java.util.List; import java.util.Random; public class MyService extends Service { private MediaPlayer mediaPlayer; private List<Music> list; private int index; private int playmode=0; public MyService() { } @Override public void onCreate() { super.onCreate(); Mybrono mybrono = new Mybrono(); IntentFilter intentFilter=new IntentFilter(); intentFilter.addAction("com.luo1"); intentFilter.addAction("com.luo21"); intentFilter.addAction("com.luo3"); intentFilter.addAction("com.luo4"); registerReceiver(mybrono,intentFilter); list=new ArrayList<>(); list=MyMusucID.getMusic(this); mediaPlayer=new MediaPlayer(); MyRever myRever=new MyRever(); IntentFilter intentFilter1=new IntentFilter(); intentFilter.addAction("com.luo"); registerReceiver(myRever,intentFilter1); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Notification.Builder builder=new Notification.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher); RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.ittop); builder.setCustomContentView(remoteViews); Notification build = builder.build(); startForeground(2,build); return super.onStartCommand(intent, flags, startId); } @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. return new MyBinder(); } public void Play(final int position) { Notification.Builder builder=new Notification.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher); RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.ittop); Intent intent1=new Intent(); Intent intent2=new Intent(); Intent intent3=new Intent(); Intent intent4=new Intent(); intent1.setAction("com.luo1"); intent2.setAction("com.luo21"); intent3.setAction("com.luo3"); intent4.setAction("com.luo4"); PendingIntent pendingIntent1=PendingIntent.getBroadcast(this,0,intent1,0); PendingIntent pendingIntent2=PendingIntent.getBroadcast(this,0,intent2,0); PendingIntent pendingIntent3=PendingIntent.getBroadcast(this,0,intent3,0); PendingIntent pendingIntent4=PendingIntent.getBroadcast(this,0,intent4,0); remoteViews.setOnClickPendingIntent(R.id.up1,pendingIntent1); remoteViews.setOnClickPendingIntent(R.id.stop1,pendingIntent2); remoteViews.setOnClickPendingIntent(R.id.js1,pendingIntent3); remoteViews.setOnClickPendingIntent(R.id.next1,pendingIntent4); remoteViews.setTextViewText(R.id.mz,list.get(index).getTitle()); builder.setCustomContentView(remoteViews); Notification build = builder.build(); startForeground(2,build); index=position; mediaPlayer.reset(); try { mediaPlayer.setDataSource(list.get(position).getData()); mediaPlayer.prepareAsync(); mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mediaPlayer.start(); switch (playmode){ case MyMusucID.ONE: index++; if(index >= list.size() -1){ index = 0; } break; case MyMusucID.TWO: break; case MyMusucID.THREE: index = new Random().nextInt(list.size()); break; } Play(index); } }); } catch (IOException e) { e.printStackTrace(); } } public void js() { mediaPlayer.start(); } public void tv1() { playmode=MyMusucID.ONE; } public void tv2() { playmode=MyMusucID.TWO; } public void tv3() { playmode=MyMusucID.THREE; } class Mybrono extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals("com.luo1")){ up(); } if (action.equals("com.luo21")){ pause(); } if (action.equals("com.luo3")){ stat(); } if (action.equals("com.luo4")){ next(); } } } private void stat() { mediaPlayer.start(); } class MyBinder extends Binder{ public MyService getServer(){return MyService.this;} } private class MyRever extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals("com.luo")){ pause(); } } } public void pause() { mediaPlayer.pause(); } public void seekTo(int progress) { mediaPlayer.seekTo(progress); } public int getMAX() { return mediaPlayer.getDuration(); } public int getProgerss() { return mediaPlayer.getCurrentPosition(); } public void next() { index++; if (index>=list.size()-1){ index=0; } Play(index); } public void up() { index--; if (index<=0){ index=0; } Play(index); } } 连接vp tb 的 package com.example.myapplication105; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import java.util.List; public class MyVpTbapdate extends FragmentStatePagerAdapter { private List<Fragment> list; private List<String> data; public MyVpTbapdate(@NonNull FragmentManager fm, List<Fragment> list, List<String> data) { super(fm); this.list = list; this.data = data; } @NonNull @Override public Fragment getItem(int position) { return list.get(position); } @Override public int getCount() { return list.size(); } @Nullable @Override public CharSequence getPageTitle(int position) { return data.get(position); } } 第一个OneFragment package com.example.myapplication105; import android.Manifest; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.media.MediaPlayer; import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.Button; import android.widget.ListView; import android.widget.PopupWindow; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; import androidx.fragment.app.Fragment; import java.util.List; import java.util.Timer; import java.util.TimerTask; /** * A simple {@link Fragment} subclass. */ public class OneFragment extends Fragment { private ListView lv; private Button stop; private Button up; private Button next; private Button js; private Button type; private List<Music> list; private Myapdate myapdate; private MyService.MyBinder binder; private SeekBar seek; private MediaPlayer mediaPlayer; private Timer timer; public OneFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment final View inflate = inflater.inflate(R.layout.fragment_one,container, false); lv = (ListView) inflate.findViewById(R.id.lv); stop = (Button) inflate.findViewById(R.id.stop); up = (Button) inflate.findViewById(R.id.up); next = (Button) inflate.findViewById(R.id.next); js = (Button) inflate.findViewById(R.id.js); type = (Button) inflate.findViewById(R.id.type); seek = (SeekBar) inflate.findViewById(R.id.seek); if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},100); } list = MyMusucID.getMusic(getContext()); Intent intent1 = new Intent(getContext(), MyService.class); getContext().startService(intent1); ServiceConnection connection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { binder = (MyService.MyBinder) service; } @Override public void onServiceDisconnected(ComponentName name) { } }; getContext().bindService(intent1,connection, Context.BIND_ABOVE_CLIENT); myapdate=new Myapdate(getContext(),list); lv.setAdapter(myapdate); seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser){ binder.getServer().seekTo(progress); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { binder.getServer().Play(position); if (timer!=null){ timer.cancel(); } timer=new Timer(); timer.schedule(new TimerTask() { @Override public void run() { getActivity().runOnUiThread(new Runnable() { @Override public void run() { seek.setMax(binder.getServer().getMAX()); seek.setProgress(binder.getServer().getProgerss()); } }); } },0,1000); } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { binder.getServer().pause(); } }); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { binder.getServer().next(); } }); up.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { binder.getServer().up(); } }); js.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { binder.getServer().js(); } }); type.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final PopupWindow popupWindow=new PopupWindow(getContext()); popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); View inflate1 = LayoutInflater.from(getContext()).inflate(R.layout.itt, null); TextView tv1= inflate1.findViewById(R.id.tv1); TextView tv2= inflate1.findViewById(R.id.tv2); TextView tv3= inflate1.findViewById(R.id.tv3); tv1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); Toast.makeText(getContext(), "随机播放", Toast.LENGTH_SHORT).show(); binder.getServer().tv1(); } }); tv2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); Toast.makeText(getContext(), "单曲播放", Toast.LENGTH_SHORT).show(); binder.getServer().tv2(); } }); tv3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); Toast.makeText(getContext(), "顺序播放", Toast.LENGTH_SHORT).show(); binder.getServer().tv3(); } }); popupWindow.setContentView(inflate1); popupWindow.setOutsideTouchable(true); popupWindow.showAsDropDown(type,0,0); } }); return inflate; } } 第二个 package com.example.myapplication105; import android.os.Bundle; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * A simple {@link Fragment} subclass. */ public class TwoFragment extends Fragment { public TwoFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_two, container, false); } } 布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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=".MainActivity" android:orientation="vertical"> <androidx.viewpager.widget.ViewPager android:id="@+id/vp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent"></androidx.viewpager.widget.ViewPager> <LinearLayout android:layout_weight="10" android:layout_gravity="center" android:orientation="horizontal" android:id="@+id/ll" android:layout_width="match_parent" android:layout_height="match_parent"></LinearLayout> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" tools:context=".Main2Activity"> <androidx.viewpager.widget.ViewPager android:id="@+id/vp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent"></androidx.viewpager.widget.ViewPager> <com.google.android.material.tabs.TabLayout android:layout_weight="10" android:id="@+id/tb" android:layout_width="match_parent" android:layout_height="match_parent"></com.google.android.material.tabs.TabLayout> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" tools:context=".BlankFragment"> <!-- TODO: Update blank fragment layout --> <ImageView android:src="@mipmap/ic_launcher" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView> </FrameLayout> <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" tools:context=".BlankFragment2"> <!-- TODO: Update blank fragment layout --> <ImageView android:src="@mipmap/ic_launcher" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView> </FrameLayout> <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" tools:context=".BlankFragment3"> <!-- TODO: Update blank fragment layout --> <TextView android:id="@+id/time" android:text="倒计时" android:layout_width="match_parent" android:layout_height="wrap_content"></TextView> <ImageView android:src="@mipmap/ic_launcher" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView> </FrameLayout> <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" tools:context=".OneFragment"> <ListView android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> <LinearLayout android:orientation="vertical" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="wrap_content"> <SeekBar android:id="@+id/seek" android:layout_width="match_parent" android:layout_height="wrap_content"></SeekBar> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/stop" android:text="停止" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/up" android:text="上一首" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/next" android:text="下一首" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/js" android:text="继续" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/type" android:text="模式" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout> </LinearLayout> </FrameLayout> <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" tools:context=".TwoFragment"> <!-- TODO: Update blank fragment layout --> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/hello_blank_fragment" /> </FrameLayout> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/ig" android:src="@mipmap/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> <TextView android:id="@+id/gm" android:text="哥名" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/gs" android:text="哥手" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> <TextView android:id="@+id/sj" android:text="时间" android:gravity="right" android:layout_weight="3" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> </LinearLayout> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="100dp"> <TextView android:id="@+id/tv1" android:layout_weight="1" android:text="随机播放" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> <TextView android:id="@+id/tv2" android:layout_weight="1" android:text="单选循环" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> <TextView android:id="@+id/tv3" android:layout_weight="1" android:text="顺序播放" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:src="@mipmap/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> <TextView android:gravity="center|left" android:text="哥名" android:id="@+id/mz" android:layout_width="match_parent" android:layout_height="match_parent"></TextView> </LinearLayout> <LinearLayout android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="match_parent"> <Button android:id="@+id/up1" android:text="上一首" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/stop1" android:text="停止" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/js1" android:text="开始" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:id="@+id/next1" android:text="下一首" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout> </LinearLayout>