【问题标题】:Imagebutton android tvImagebutton 安卓电视
【发布时间】:2015-10-31 19:06:42
【问题描述】:

经过几次尝试,我成功地作为一个 Imagebutton,android 电视遥控器工作。 但是选择了添加按钮,或者至少在选择时看不到差异。 我试过专注。但按钮并不完全静止,看看它是否被选中。 我能做些什么 ? 谢谢。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="ro.vrt.virtualespanatv.AndroidTv"
style="@style/Theme.Leanback.Browse"
android:background="@drawable/background">



<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView2" >

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

        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/horizontalScrollView4" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <com.google.android.gms.ads.AdView
                    android:id="@+id/adView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    ads:adSize="BANNER"
                    ads:adUnitId="@string/banner_ad_unit_id"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentStart="false">
                </com.google.android.gms.ads.AdView>
            </RelativeLayout>
        </HorizontalScrollView>

        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/horizontalScrollView5"
            android:layout_below="@+id/horizontalScrollView4"
            android:layout_alignLeft="@+id/horizontalScrollView4"
            android:layout_alignStart="@+id/horizontalScrollView4">

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


                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/Categoria1"
                    android:focusable="true"
                    android:src="@drawable/tdt"
                    android:background="@android:color/transparent"
                    android:nextFocusRight="@+id/Categoria2"
                    android:nextFocusUp="@+id/adView"
                    android:scaleType="fitXY"
                    style="@android:style/MediaButton.Rew" />

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/Categoria2"
                    android:focusable="true"
                    android:src="@drawable/tdt"
                    android:layout_alignParentBottom="true"
                    android:layout_toRightOf="@+id/Categoria1"
                    android:layout_toEndOf="@+id/Categoria1"
                    android:focusableInTouchMode="true"
                    android:clickable="true"/>

            </RelativeLayout>
        </HorizontalScrollView>

    </RelativeLayout>
</ScrollView>

【问题讨论】:

标签: android android-layout android-tv


【解决方案1】:

只需将属性android:foreground="?attr/selectableItemBackground" 添加到您的ImageView 即可显示效果。

【讨论】:

    猜你喜欢
    • 2017-12-06
    • 2021-02-18
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 2023-01-24
    • 1970-01-01
    • 2017-04-30
    • 2022-11-18
    相关资源
    最近更新 更多