Android Studio安卓开发-RecycleView新闻栏设计

绪言

在上一博客中,我们完成类微信UI开发,在此基础上,在联系人界面实现RecycleView的简单用例,在发现界面实现RecycleView的流式布局。如下图所示。
联系人界面-RecycleView简单用例
发现界面-RecycleView流式布局

对于RecycleView的基础布局学习我们先到这,现在需要我们对每一个RecycleView的Item实现点击操作,能够跳转至Item的详情界面,下面我们以新闻栏的设计进行学习。

1 修改Item_dome.xml文件

我们已经在联系人界面contacts.xml文件中,添加RecycleView,并进行Item_dome.xml文件的编写,在上一实践中,我们仅仅为每个Item设计一个图片、一个Title和一个边框,现在我们需要为每个Item添加一个introduction,用于作为新闻的导语,介绍新闻的主要内容。
在这一部分,我们使用到两个LinearLayout,需要注意的是,在父LinearLayout中,我们布局一个ImageView和一个子LinearLayout,它们是平行的,在子LinearLayout中,我们有两个TextView,一个title_textview用于作为新闻的标题,一个introduction_textview用于作为新闻的导语。

<?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:id="@+id/news_item"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_marginLeft="40dp"
    android:layout_marginTop="15dp"
    android:layout_marginRight="40dp"
    android:layout_marginBottom="15dp"
    android:background="@drawable/text_view_shape"
    android:gravity="center"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_weight="1"
        tools:srcCompat="@tools:sample/avatars" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="TextView"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/introduction_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="5"
            android:textSize=
  • 1
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值