質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Android Widget

ホームスクリーンウィジェット、またはAndroidアプリケーションのスクリーン上で使用される一般的なユーザインタフェース要素に関連することを指します。

Q&A

0回答

1129閲覧

AndroidのListPopupWindowでアニメーションを消去したい

hobby2018

総合スコア22

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Android Widget

ホームスクリーンウィジェット、またはAndroidアプリケーションのスクリーン上で使用される一般的なユーザインタフェース要素に関連することを指します。

0グッド

0クリップ

投稿2021/05/13 13:13

編集2021/05/14 00:03

material.ioList popup window menusでリスト表示のアニメーションを消去したいのですが、listPopupWindow.animationStyle = 0とやってもうまく消えてくれません。

listPopupWindow.animationStyle = 0で、
ListPopupWindowsetAnimationStyleが呼ばれその内部で
PopupWindowに(mPopup)setAnimationStyleanimationStyleをセットしています。

PopupWindowsetAnimationStyleには、ドキュメントにアニメーション無しは0(0 for no animation)と書かれています。

どなたかお知恵を頂けないでしょうか?

public class ListPopupWindow implements ShowableListMenu { PopupWindow mPopup; /** * Set an animation style to use when the popup window is shown or dismissed. * * @param animationStyle Animation style to use. */ public void setAnimationStyle(@StyleRes int animationStyle) { mPopup.setAnimationStyle(animationStyle); } public class PopupWindow { /** * <p>Change the animation style resource for this popup.</p> * * <p>If the popup is showing, calling this method will take effect only * the next time the popup is shown or through a manual call to one of * the {@link #update()} methods.</p> * * @param animationStyle animation style to use when the popup appears * and disappears. Set to -1 for the default animation, 0 for no * animation, or a resource identifier for an explicit animation. * * @see #update() */ public void setAnimationStyle(int animationStyle) { mAnimationStyle = animationStyle; }

Kotlin

1class FirstFragment : Fragment() { 2 3 override fun onCreateView( 4 inflater: LayoutInflater, container: ViewGroup?, 5 savedInstanceState: Bundle? 6 ): View? { 7 // Inflate the layout for this fragment 8 val view = inflater.inflate(R.layout.fragment_first, container, false) 9 10 val listPopupWindowButton = view.findViewById<Button>(R.id.list_popup_button) 11 val listPopupWindow: ListPopupWindow = ListPopupWindow(requireContext(), null, R.attr.listPopupWindowStyle) 12 13 // Set button as the list popup's anchor 14 listPopupWindow.anchorView = listPopupWindowButton 15 16 // Set list popup's content 17 val items = listOf("Option 1", "Option 2", "Option 3") 18 val adapter = ArrayAdapter(requireContext(), R.layout.list_popup_window_item, items) 19 listPopupWindow.setAdapter(adapter) 20 21 // Set list popup's item click listener 22 listPopupWindow.setOnItemClickListener { parent: AdapterView<*>?, view: View?, position: Int, id: Long -> 23 // Respond to list popup window item click. 24 25 // Dismiss popup. 26 listPopupWindow.dismiss() 27 } 28 29 // Show list popup window on button click. 30 listPopupWindowButton.setOnClickListener { v: View? -> listPopupWindow.show() } 31 32 // アニメーションがオフにならない??? 33 listPopupWindow.animationStyle = 0 34 35 return view 36 }

XML

1layout/list_popup_window_item 2 3<TextView xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="match_parent" 5 android:layout_height="wrap_content" 6 android:ellipsize="end" 7 android:maxLines="1" 8 android:padding="16dp" 9 android:textAppearance="?attr/textAppearanceSubtitle1" />

XML

1fragment_first 2 3<?xml version="1.0" encoding="utf-8"?> 4<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:app="http://schemas.android.com/apk/res-auto" 6 xmlns:tools="http://schemas.android.com/tools" 7 android:layout_width="match_parent" 8 android:layout_height="match_parent" 9 tools:context=".FirstFragment"> 10 11 <Button 12 android:id="@+id/list_popup_button" 13 android:layout_width="match_parent" 14 android:layout_height="wrap_content" 15 app:layout_constraintBottom_toTopOf="parent" 16 app:layout_constraintLeft_toLeftOf="parent" 17 app:layout_constraintRight_toRightOf="parent" 18 app:layout_constraintTop_toTopOf="parent" 19 android:text="show_menu"/> 20 21</androidx.constraintlayout.widget.ConstraintLayout>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問