1

私は、ユーザーが会社のボイスメールシステムにアクセスできるようにするアプリを書いています。ボイスメールはリストビューに表示され、選択するとメニューが表示されます。ユーザーが「リッスン」を選択すると、画面下部の既存のリストビューの上に小さなメディアプレーヤーがポップアップ表示されます(ソフトキーボードが必要なときに起動し、終了すると消えるのと同じです)。

オプション?

4

1 に答える 1

4

すべてのビュー(つまり、ListView)をRelativeLayoutに追加し、メディアプレーヤーのレイアウト要素を下部に配置し、それらの可視性を消えるように設定します。

<RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >

  <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

  <RelativeLayout
    android:id="@+id/mediaPopup"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" 
    android:visibility="gone"
    >
    <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="I am a media player!"
      />
  </RelativeLayout>

</RelativeLayout>

次に、アクティビティクラスで、次のようにビューをアニメーション化できます。

function void showMediaPlayer() {

  if(mMediaPopUp.getVisibility() == View.GONE) {

    // Show Media Player
    TranslateAnimation mAnimUp = 
      new TranslateAnimation(
        Animation.RELATIVE_TO_SELF, 
        0, 
        Animation.RELATIVE_TO_SELF, 
        0, 
        Animation.RELATIVE_TO_SELF, 
        -(mMediaPopUp.getHeight()), 
        Animation.RELATIVE_TO_SELF, 
        0);

    mAnimUp.setStartOffset(500);
    mAnimUp.setDuration(500);

    mMediaPopUp.setVisibility(View.VISIBLE);
    mMediaPopUp.setAnimation(mAnimUp);

  }
}
于 2010-06-03T15:14:12.933 に答える