AndroidTVWidget use manual

AndroidTVWidget use manual

https://github.com/FrozenFreeFall/Android-tv-widget

【开始使用AndroidTVWidget控件】

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <!-- 最顶层的边框移动 -->
    <com.open.androidtvwidget.view.MainUpView
        android:id="@+id/mainUpView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </com.open.androidtvwidget.view.MainUpView>

</LinearLayout>

图片橙色的矩形方框就是 MainUpView 控件.

输入图片说明 输入图片说明输入图片说明

如果想更换边框的图片,请使用 setUpRectDrawable, setUpRectResource 都可以设置边框样式.

public void setUpRectDrawable(Drawable upRectDrawable)

public void setUpRectResource(int resId)

public class MainActivity extends Activity {

    MainUpView mMainUpView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);
        mMainUpView = (MainUpView) findViewById(R.id.mainUpView);
        Drawable testDrawable = null;
        mMainUpView.setUpRectDrawable(testDrawable); // 设置边框图片
        mMainUpView.setUpRectResource(R.drawable.white_light_10); // 设置边框图片.
    }

}

如果边框自带了阴影效果,超出了,那就使用

public void setDrawUpRectPadding(int size) { // 根据图片边框 自行 填写 相差的边距.

public void setDrawUpRectPadding(Rect rect) { // 根据图片边框 自行 填写 相差的边距.

来调整距离(负数是扩大距离,正数是缩小距离)。

MainUpView 如果 使用 setUpRect... 设置了一个边框,但是想在边框后面添加阴影这么办?

使用函数 设置阴影.

public void setShadowDrawable(Drawable shadowDrawable)

public void setShadowResource(int resId)

如果阴影的距离也不对,可以使用函数 setShadowPadding 来调整距离.




【如何添加倒影】

输入图片说明

输入图片说明

倒影控件 ReflectItemView XML布局中设置 app:isReflect="true",记得要加上这个(xmlns:app="http://schemas.android.com/apk/res-auto"),才能添加此属性,

【如何添加标签控件】

输入图片说明

LabelView

    <com.open.androidtvwidget.view.LabelView
                    xmlns:lv="http://schemas.android.com/apk/res-auto"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    lv:lv_background_color="#3F9FE0"
                    lv:lv_fill_triangle="true"
                    lv:lv_gravity="TOP_RIGHT"
                    lv:lv_text="热门"
                    lv:lv_text_size="18sp" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#222831"
    android:gravity="center"
    android:orientation="vertical"
    android:paddingLeft="40dp"
    android:paddingRight="40dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.flyco.labelviewsample.MainActivity"
    tools:showIn="@layout/activity_main">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="centerCrop"
            android:src="@mipmap/beauty"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            lv:lv_text="Hot"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            lv:lv_background_color="#3F9FE0"
            lv:lv_gravity="TOP_RIGHT"
            lv:lv_text="纯♀妹子"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|left"
            lv:lv_background_color="#F6CE59"
            lv:lv_gravity="BOTTOM_LEFT"
            lv:lv_text="Gank.io"
            lv:lv_text_all_caps="false"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            lv:lv_background_color="#EC7263"
            lv:lv_gravity="BOTTOM_RIGHT"
            lv:lv_text="new"/>
    </FrameLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="centerCrop"
            android:src="@mipmap/beauty"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            lv:lv_fill_triangle="true"
            lv:lv_text="新"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            lv:lv_background_color="#3F9FE0"
            lv:lv_fill_triangle="true"
            lv:lv_gravity="TOP_RIGHT"
            lv:lv_text="妹子"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|left"
            lv:lv_background_color="#F6CE59"
            lv:lv_fill_triangle="true"
            lv:lv_gravity="BOTTOM_LEFT"
            lv:lv_text="Gank.io"
            lv:lv_text_all_caps="false"
            lv:lv_text_size="12sp"/>

        <com.flyco.labelview.LabelView
            xmlns:lv="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            lv:lv_background_color="#EC7263"
            lv:lv_fill_triangle="true"
            lv:lv_gravity="BOTTOM_RIGHT"
            lv:lv_text="new"/>
    </FrameLayout>
</LinearLayout>

输入图片说明

根据 lv:lv_gravity="BOTTOM_RIGHT" 设置显示位置.

根据 lv:lv_text="new" 设置显示的文本.

根据 lv:lv_fill_triangle="true" 设置是否占满.

具体可以参考: https://github.com/FrozenFreeFall/FlycoLabelView

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值