Media Images Video and Sound

2017-02-17  本文已影响0人  LeonaLiu

小发现

counter.animate().translationYBy(1000f).rotation(360).setDuration(300);
//1000f 的f是float的意思,因为参数要求float类型
        VideoView videoView = (VideoView) findViewById(R.id.videoView);
        videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.demovideo);

        MediaController mediaController = new MediaController(this);

        mediaController.setAnchorView(videoView);

        videoView.setMediaController(mediaController);

        videoView.start();
        MediaPlayer mplayer = MediaPlayer.create(this, R.raw.laugh);

        audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
        int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

        SeekBar volumeControl = (SeekBar)findViewById(R.id.seekBar);
        volumeControl.setMax(maxVolume);
        volumeControl.setProgress(curVolume);

GridLayout的一些小技巧

1. 如果API21以上是可以直接使用,以 android:开头

<GridLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_row="0"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:layout_gravity="fill"
            android:text="Hello"
            android:onClick="buttonTapped"
            android:id="@+id/hello" /> 
</GridLayout>

2. 如果是API 21 以下的,以上提到的属性,需用support 库:com.android.support:gridlayout-v7:24.2.1',还要把上述属性改为app:及tag名称修改。

   <android.support.v7.widget.GridLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:columnCount="2"
        app:rowCount="4"
        app:orientation="vertical"
        >
       <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_column="0"
            app:layout_row="0"
            app:layout_columnWeight="1"
            app:layout_rowWeight="1"
            app:layout_gravity="fill"
            android:text="Hello"
            android:onClick="buttonTapped"
            android:id="@+id/hello" />
 </android.support.v7.widget.GridLayout>```
上一篇下一篇

猜你喜欢

热点阅读