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>

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

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

  • 相关阅读:
    window+Apache+php+mysql注意事项
    【转】QRCode二维码的应用心得
    如何创建和配置服务器证书进行SSL Relay
    Citrix 实践中的问题及解决
    web.config中httpRunTime的属性
    [原]IE9 DOM的自定义属性问题
    添加图片到数据库
    Windows server 2008安装企业CA证书服务
    EXTJS Date 的转换格式化字符
    Extjs 4.1 学习笔记(一)(proxy,loader,treestore)
  • 原文地址:https://www.cnblogs.com/20183711PYD/p/12261089.html
Copyright © 2011-2022 走看看