前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android:新闻类应用布局、分割线

Android:新闻类应用布局、分割线

作者头像
zstar
发布2022-06-14 10:36:25
5630
发布2022-06-14 10:36:25
举报
文章被收录于专栏:往期博文往期博文

想做一个新闻类应用,类似今日资讯 先上效果

在这里插入图片描述
在这里插入图片描述

每篇文章之间的分割线有两种思路可以做 第一种,背景灰色,设置卡片间距 第二种,直接用shape画 这里采用第二种方法

首先在drawable里面建dash_line文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >

    <!--线宽为dashWith,线之间空隙dashGap,dashGap=0dp时,是实线 -->
    <stroke
        android:dashGap="0dp"
        android:dashWidth="30dip"
        android:width="1dip"
        android:color="@android:color/darker_gray" />

    <!-- 虚线高度 -->
    <size android:height="1dip" />

</shape>

之后在布局中引入

代码语言:javascript
复制
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/white">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp">

            <ImageView
                android:layout_width="10dp"
                android:layout_height="100dp"
                android:scaleType="fitXY"
                android:layout_weight="1"
                android:src="@drawable/pc1"></ImageView>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="这是文章标题"
                    android:textSize="30dp"
                    android:textStyle="bold"
                    android:textColor="@color/black"
                    android:paddingLeft="10dp"></TextView>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="作者:"
                    android:textSize="25dp"
                    android:paddingLeft="10dp"
                    ></TextView>

            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_marginTop="10dp"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:background="@drawable/dash_line"
            android:layerType="software"
            android:orientation="horizontal" />

    </LinearLayout>

想要多个,多复制几个即可

参考资料:Android分割线divider

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-04-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档