仿抖音短视频APP源码,滚动视图相关的代码
在xml中添加滚动视图
垂直方向上滚动

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/content"android:textSize="25sp"/></ScrollView></RelativeLayout>

水平方向上滚动:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><HorizontalScrollView android:layout_width="wrap_content"android:layout_height="match_parent"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/content"android:textSize="25sp"/></HorizontalScrollView></RelativeLayout>

在滚动视图中放置多个组件
在一个滚动视图中只能放置一个组件,如果想要放置多个,需要使用布局管理器,将多个组件包括起来:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><HorizontalScrollView android:layout_width="wrap_content"android:layout_height="match_parent"><LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/content"android:textSize="25sp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/content"android:textSize="25sp"/></LinearLayout></HorizontalScrollView></RelativeLayout>

在Java文件中添加
1、使用构造方法ScrollView(Context c)创建一个滚动视图
2、应用addView()方法添加组件到滚动视图中
3、将滚动视图添加到布局管理器中
xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:id="@+id/ll"tools:context=".MainActivity"></LinearLayout>

java:

package com.example.scrollview;import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//创建布局管理器LinearLayout linearLayout=findViewById(R.id.ll);LinearLayout linearLayout1=new LinearLayout(MainActivity.this);linearLayout1.setOrientation(LinearLayout.VERTICAL);//将滚动视图添加到布局管理器中ScrollView scrollView=new ScrollView(MainActivity.this);linearLayout.addView(scrollView);scrollView.addView(linearLayout1);//创建图片视图ImageView imageView=new ImageView(MainActivity.this);imageView.setImageResource(R.drawable.cloud);linearLayout1.addView(imageView);TextView textView=new TextView(MainActivity.this);textView.setText(R.string.content);linearLayout1.addView(textView);}
}

以上就是 仿抖音短视频APP源码,滚动视图相关的代码,更多内容欢迎关注之后的文章

仿抖音短视频APP源码,滚动视图相关推荐

  1. 仿抖音短视频APP源码如何开发抖音类似特效

    仿抖音短视频APP源码如何开发抖音类似特效 1.特效概览 特效列表 特效列表 2.『灵魂出窍』 抖音的实现效果如下: 灵魂出窍 我的实现效果如下: ezgif.com-rotate.gif 代码实现 ...

  2. 如何开发仿抖音短视频APP源码?

    如何开发仿抖音短视频APP源码? 流程列表 开发一个短视频最主要的流程分为 3 个,下面我将分步教你实现这 3 个流程下的各个功能点,功能点 API 可按需调用: 视频拍摄 a.启动拍摄 b.给拍摄添 ...

  3. 仿抖音短视频APP源码,顶部导航栏切换详解

    仿抖音短视频APP源码,顶部导航栏切换详解的相关代码 class DaoHangNan extends StatefulWidget //继承StatefulWidget{TabController ...

  4. 仿抖音短视频APP源码,底部弹窗对话框

    仿抖音短视频APP源码,底部弹窗对话框的相关代码 核心代码 final Dialog dialog = new Dialog(this, R.style.BottomDialogStyle); Vie ...

  5. 仿抖音短视频APP源码,刷新屏幕计时,重置系统休眠计时

    仿抖音短视频APP源码,刷新屏幕计时,重置系统休眠计时的相关代码,可同时实现息屏状态下亮屏, 或者即将息屏时, 重置系统休眠计时 PowerManager mPowerManager = (Power ...

  6. 短视频源码仿抖音短视频APP源码短视频平台源码短视频源码

    [WoShop仿抖音短视频源码的主要功能] 1.短视频带货:关联商品的短视频封面会有商品标识,短视频内容中会弹出商品链接 2.直播带货:短视频源码支持直播功能,直播间内可开启带货功能 3.邀请赚钱:用 ...

  7. 仿抖音短视频APP源码android布局悬停顶部效果

    实现: 1.导入design库 implementation 'com.android.support:design:28.0.0' 2.布局 <android.support.design.w ...

  8. 仿抖音短视频APP源码Android轻松实现日期选择器、生日选择器、自定义起始时间

    代码实现 代码实现比较简单 按照步骤 你也可以实现同样的效果 第一步 设置依赖 android 和androidX都可以 //时间选择器 implementation 'com.contrarywin ...

  9. 仿抖音短视频APP源码html网页图片和文字水平居中垂直居中显示

    div相对于页面水平居中显示: 核心代码:margin:0 auto: /意思为:div的外边距上下为0px,左右居中显示;/ /前提是position为相对定位;不能为absolute绝对定位/ * ...

最新文章

  1. 32位dll注入到64位程序_你用的32位还是64位?有什么区别呢?
  2. 《坐热板凳》第八次团队作业:Alpha冲刺(第二天)
  3. aⅴgo安装包下载_Mysql 安装
  4. example datasets in sklearn
  5. 倒立摆入门详解+pid调参
  6. 腾讯云灯塔计划——云行业研究报告
  7. Ubuntu内核升级导致显卡冲突,升级显卡并禁用自动更新教程
  8. java中怎么保留小数_java怎么保留小数
  9. 2015美团算法工程师笔试、面试之旅
  10. Word文件打开的时候需要输入密码?
  11. 中蜂几月份自然分蜂_中蜂一年自然分蜂几次?_库百科养蜂养殖
  12. AI元宇宙数字人直播带货软件 全天24小时直播带货系统 含搭建教程
  13. 开启ICT宝藏之门——CloudOpera IES 创新社区正式成立
  14. 蓝牙【GATT】协议介绍
  15. iOS 音频视频制作
  16. mac使用git管理Github
  17. 使用threejs和canvas创建中文文字精灵
  18. 关于视频软件开发的技术
  19. filemanager-webpack-plugin 打包自动压缩zip
  20. 神奇的算法(一):欧几里德算法

热门文章

  1. 3D Human Body Reconstruction from a Single Image via Volumetric Regression笔记
  2. poj 1852 Ants
  3. pythonurllib新浪微博_Python 爬虫如何机器登录新浪微博并抓取内容?
  4. oracle rac lrm 00109,ORA-01078 LRM-00109 解决方案 RAC ASM
  5. 矩阵分解---LDL分解
  6. 百度云盘可以与计算机硬盘,百度网盘上线“工作空间”功能
  7. 【爬虫知识】2022年python最新前沿技术?通过pyscript写爬虫程序
  8. java学生成绩分析系统spring源码
  9. ai面试的优缺点_分享:我在利洁面试的一些经验
  10. 社区发现算法——LPA与SLPA算法