Android 进阶开发第一天-网络数据的访问导入(上篇)

现在已经有了开发一个小程序APP的基础,接下来我们要学习android stdio更高级的的功能了。
先来看看今天所学习知识的要求
开发工具:android stdio
实现目标,按一个按钮来访问网络文件信息,按另一个按钮来访问图片信息(以前学习的是访问本地文件)
现在开始进行网络访问的操作。
刚开始肯定是布局了,布局后图如下所示。
布局需要注意的知识点
1:我用的布局方式是LinearLayout线性布局
2:布局里面的单元尽量少用wrap_content,尽量用一些具体度量值来替代,为什么呢,因为wrap_content指代的单元在布局过程中是可以变化的,不利于我们随时形象观察其具体的状态。
3:最重要的一点—布局要经过不断调试来找出适合自己的布局方式。
首先我们来看一下这个布局图,如下:
布局图
这个布局图的代码如下

<?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:orientation="vertical"
    android:gravity="center|top"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.again.againActivity">

    <Button
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:id="@+id/left"
        android:onClick="leftbutton"
        android:textSize="20dp"
        android:text="上边"
        />
    <Button
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:onClick="rightbutton"
        android:text="下边"
        android:textSize="20dp"
        android:id="@+id/right"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:id="@+id/tex"
        android:textSize="30dp"
        />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:id="@+id/grid"
            >

        </GridLayout>
    </ScrollView>
</LinearLayout>

这里面提一个知识点,ScrollView是一个整体布局,其中的GridLayout用来存放image等视图图片的信息。
另一个知识点是:这里是线性布局,不要和其它布局相互冲突了,例如
android:layout_width=“match_parent”/ android:layout_height="150dp"是线性布局
android:rowCount=“1”/ android:columnCount="4"是单元布局
两个布局不要放在一个模块!
接下来进入我们的重头戏,由于篇幅较长,所以放在下一篇来介绍。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值