Android:新闻类应用布局、分割线
2023-09-14 09:01:37 时间
想做一个新闻类应用,类似今日资讯
先上效果
每篇文章之间的分割线有两种思路可以做
第一种,背景灰色,设置卡片间距
第二种,直接用shape画
这里采用第二种方法
首先在drawable里面建dash_line文件:
<?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>
之后在布局中引入
<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
相关文章
- xps 转 pdf android版,xps文件转换pdf
- android应用程序_chrome Android
- Android 项目开发填坑记 - 谷歌商店上架被拒 Apps On Device
- android scaleanimation动画,Android 动画之ScaleAnimation应用详解「建议收藏」
- 【Android 应用开发】Android 平台 HTTP网速测试 案例 API 分析
- 【Android 应用开发】UI绘制流程 ( 生命周期机制 | 布局加载机制 | UI 绘制流程 | 布局测量 | 布局摆放 | 组件绘制 | 瀑布流布局案例 )
- 【Android 应用开发】Android 返回堆栈管理 ( 默认启动模式 | 栈顶复用启动模式 | 栈内复用启动模式 | 单实例启动模式 | CLEAR_TOP 标识 )
- 【Android 应用开发】Activity 返回堆栈管理 ( 栈内复用模式 singleTask | 单实例模式 singleInstance )
- 【Android 性能优化】应用启动优化 ( 阶段总结 | Trace 文件分析及解决方案 | 源码分析梳理 | 设置主题的方案总结 ) ★
- 【Android 安全】DEX 加密 ( 阶段总结 | 主应用 | 代理 Application | Java 工具 | 代码示例 ) ★
- 【Android 文件管理】应用可访问的存储空间 ( 存储空间分类 | 存储空间访问权限 | 分区存储 )
- 【Android 安装包优化】Android 中使用 SVG 图片 ( 批量转换 SVG 格式图片为 Vector Asset 矢量图资源 )
- 【Android 插件化】Hook 插件化框架 ( 通过反射获取 “宿主“ 应用中的 Element[] dexElements )
- 【Android 逆向】应用数据目录 ( Android 应用数据目录 /data/data/package.name | 存放 SharedPreference 的 shared_pref 目录 )
- 【Android 逆向】Android 进程注入工具开发 ( 调试进程中寄存器的作用 | 通过 EIP 寄存器控制程序运行 | EIP 寄存器的存档与恢复 )
- 【Google Play】Android 应用用户协议 ( 生成用户协议 | HTML 用户协议模板 | Markdown 用户协议模板 )
- 【错误记录】未安装该应用 ( 在 Android 12 之后 组件设置 android:exported=“false“ 属性 )
- Android开发中遇到的问题(三)——eclipse创建android项目无法正常预览布局文件详解手机开发
- [android] 手机卫士手机定位的原理详解手机开发
- [android] 采用服务执行长期后台的操作详解手机开发
- 亚马逊带广告的IMDb TV服务终于推出了Android和iOS应用
- python服务器与android客户端socket通信实例
- Android实用图文教程之代码混淆、第三方平台加固加密、渠道分发