小發(fā)現(xiàn)
-
imageView 有個onClick的屬性蔑舞;
-
imageView 的動畫方法 animate(), translation打頭的是移動含義衡查;
counter.animate().translationYBy(1000f).rotation(360).setDuration(300);
//1000f 的f是float的意思矾芙,因為參數(shù)要求float類型
-
VideoView可以用來播放視頻,以下是demo代碼
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用于播放音頻假抄,可以關(guān)聯(lián) seekBar 來控制進度 和 音量,以下是demo代碼
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的一些小技巧
- GridLayout中的* layout_column踏志,layout_row阀捅,layout_columnWeight,layout_rowWeight针余,layout_gravity饲鄙,orientation,columnCount圆雁,rowCount*
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>```
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者