zoukankan      html  css  js  c++  java
  • 【家庭记账本】Android开发日记(三)

      今日熟悉了android studio中的其他常用控件,以及线性布局的嵌套使用。

      Android Studio中控件不只是textview(文本),button(按钮),还有输入框,插入图片等控件。其中在学习插入图片时我认识了drawable文件夹,这个文件夹是用来存放图片的,使用时直接通过android:src="@drawable/图片名称"即可调用,以下是练习时写下的代码

    <?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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center_horizontal"
        tools:context=".MainActivity">
    
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="Hello World!"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="这是一个按钮"
            />
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="下面是一个输入框"
            />
    
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="right">
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="嵌套后的按钮"
            />
            </LinearLayout>
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:textSize="50dp"
            android:text="插入图片"
            />
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/picture1"
            />
    </LinearLayout>

    使用模拟器打开的界面效果不太一样,先附上手机样式的图片效果:

     使用虚拟机的演示效果(在输入框里写入文本)

  • 相关阅读:
    电脑一族,打电脑时候的健康的坐姿
    根据时间戳,增量同步数据的解决办法
    写在前面
    《T-GCN: A Temporal Graph Convolutional Network for Traffic Prediction》 论文解读
    关于Graph Convolutional Network的初步理解
    图形学_opengl纹理映射
    推荐算法_CIKM-2019-AnalytiCup 冠军源码解读_2
    推荐算法_CIKM-2019-AnalytiCup 冠军源码解读
    leetcode_雇佣 K 名工人的最低成本(优先级队列,堆排序)
    图形学_Bezier曲线
  • 原文地址:https://www.cnblogs.com/20183711PYD/p/12261089.html
Copyright © 2011-2022 走看看