内容简介:执行逻辑
布局 activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
tools:ignore="ContentDescription,HardcodedText,UselessParent">
<LinearLayout
android:id="@+id/screenshotLayout"
android:layout_width="310dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="25dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:background="@drawable/bg_qr_code"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="17dp">
<ImageView
android:id="@+id/iv_avatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:src="@drawable/qq" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/iv_avatar"
android:text="QQ"
android:textColor="#000000"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@id/tv_name"
android:layout_below="@id/tv_name"
android:text="好友"
android:textColor="#9b9b9b"
android:textSize="14sp" />
</RelativeLayout>
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24dp"
android:src="@drawable/generate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="27dp"
android:layout_marginTop="23dp"
android:text="扫一扫加为好友"
android:textColor="#6c6b6e"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>
执行逻辑
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
screenshotLayout.setOnClickListener { screenShot() }
}
private fun screenShot() {
screenshotLayout.isDrawingCacheEnabled = true
val bitmap = screenshotLayout.getDrawingCache(false)
screenshotLayout.destroyDrawingCache()
bitmap.toString() // Bitmap to save.
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 前端字体截取:实战篇
- 前端字体截取
- Apache Pig字符串截取实战小例子
- Apache Pig字符串截取实战小例子
- Apache Pig字符串截取实战小例子
- 用 puppeteer 实现网站自动分页截取的趣事
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Visual C# 2008入门经典
James Foxall / 张劼 / 人民邮电出版社 / 2009-6 / 39.00元
《Visual C#2008入门经典》分为五部分,共24章。第一部分介绍了Visual C# 2008速成版开发环境,引导读者熟练使用该IDE;第二部分探讨如何创建应用程序界面,包含窗体和各种控件的用法;第三部分介绍了编程技术,包括编写和调用方法、处理数值、字符串和日期、决策和循环结构、代码调试、类和对象的创建以及图形绘制等;第四部分阐述了文件和注册表的处理、数据库的使用和自动化其他应用程序等;第......一起来看看 《Visual C# 2008入门经典》 这本书的介绍吧!
RGB HSV 转换
RGB HSV 互转工具
HEX HSV 转换工具
HEX HSV 互换工具