我有一个 View (假设它是 MyFramLayout
)扩展了 FrameLayout,我无法在按下键时让这个 FrameLayout 获得焦点(我在电视平台上工作)。
布局是这样的:
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.roger.MyFrameLayout
android:id="@android:id/my_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true" />
</LinearLayout>
无论如何要解决这个问题?
最佳答案
每当您希望自定义布局获得焦点时,您都必须调用
boolean b = yourLayout.requestFocus();
这将返回是否获得焦点。
关于android - FrameLayout 无法通过按键获取焦点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233840/